Sql server Continuous scanning - clarification?

I read this article about Permanent Scanning, but still do not understand when it will be used (people commented on the author that his article is still not understood):

MSDN:

The Constant Scan statement enters one or more constant lines into the query. The Compute Scalar statement is often used to add columns to a row created by the Constant Scan statement.

very unclear.

For instance:

why SELECT TOP 1 GETDATE() produces:

enter image description here

So far, select getdate() does not produce anything. (in terms of implementation).

I assume this is due to constant viewing. So:

Question:

  • What is continuous scanning
  • Why would he need to scan something, if it is permanent, and
  • Why select top 1 getdate() gives an excellent result than regular select getdate()
+6
source share
1 answer

Since most of the operators that are used when executing the query are defined in terms of one or more input sets of strings and one or more output sets of strings, it makes sense that if you write a query that requires the use of one of these operators, you must make sure that the input which you represent to this operator is a collection of strings.

Thus, the constant check operator is a special operator that can take one or more scalar inputs and generate a set of strings.

This simplifies the compilation of statements.


Why select top 1 getdate() gives a different result than regular select getdate()

Because you asked to use the TOP operator. And the TOP statement expects a set of input lines.


Why I think focusing on performance doesn't matter:

 SET STATISTICS TIME ON GO SELECT TOP 1 GETDATE() GO SELECT GETDATE() 

Messages:

  SQL Server parse and compile time: 
    CPU time = 0 ms, elapsed time = 0 ms.

  SQL Server Execution Times:
    CPU time = 0 ms, elapsed time = 0 ms.
 SQL Server parse and compile time: 
    CPU time = 0 ms, elapsed time = 0 ms.

 (1 row (s) affected)

  SQL Server Execution Times:
    CPU time = 0 ms, elapsed time = 0 ms.
 SQL Server parse and compile time: 
    CPU time = 0 ms, elapsed time = 0 ms.

 (1 row (s) affected)

  SQL Server Execution Times:
    CPU time = 0 ms, elapsed time = 0 ms.

That is, we cannot even get a measure of the time that any operator should perform.

+7
source

Source: https://habr.com/ru/post/972230/


All Articles