Solved

constant scan in execution plan

Posted on 2009-04-13
3
1,926 Views
Last Modified: 2012-05-06
I have found a constant scan in my execution plan. Can someone tell me under what condition a constant scan would happen.
0
Comment
Question by:david_32
3 Comments
 
LVL 12

Expert Comment

by:udayakumarlm
ID: 24135890
it looks like you are using GETDATE() function in a insert statement or do you have a partitioned table.
read more at
http://scarydba.wordpress.com/2008/07/01/constant-scan-in-execution-plans/
0
 
LVL 57

Accepted Solution

by:
Raja Jegan R earned 500 total points
ID: 24136248
Its not that you will obtain a Constant Scan when you use a partitioned table.

From MSDN,

Constant Scan

The Constant Scan logical and physical operator introduces a constant row into a query. It will return either zero or one row, which usually contains no columns. A Compute Scalar operator is often used to add columns to the row produced by a Constant Scan.

When you add a new column to a row / Result set using a Scalar function, then you will have a Constant Scan.

Say you have a function named dbo.format and if you use it in your query like

SELECT col1, col2, dbo.format(col3)
FROM urtable

It will have a constant scan.

Whenever you have a scalar function in your query to return some value, For eg, GETDATE() as mentioned earlier, SUBSTRING, LEN, CONVERT, CAST
You will end up in a constant scan.
0
 

Author Closing Comment

by:david_32
ID: 31569796
thanks
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
format nvarchar field as mm/dd/yyyy 4 71
Help with SQL joins 9 48
Restrict result set 1 39
create insert script based on records in a table 4 21
I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question