SQL Recipes
A FREE cookbook for SQL queries and examples
Register FAQ Search Today's Posts Mark Forums Read

SQL - Questions and Answers Have a SQL question? Post it here. First do a search to see if someone hasn't already answered it.

Go Back   SQL Recipes a FREE cookbook of SQL queries and examples > SQL queries and examples > SQL - Questions and Answers

Reply
 
LinkBack Thread Tools Search this Thread
  #1 (permalink)  
Old 07-16-2008, 10:05 PM
Unregistered
 
Posts: n/a
Default ANY dialect question:

Which Plan is the most efficient one?


Hello,

I have been trying to fine tune a query that involves this one table. The table contains 725,027 rows.

Plan 1
The original query completes in 6.2 seconds. The optimizer makes use of the clustered index. Performs a clustered index scan. The primary key is not used in the query.
Physical operation: Clustered Index Scan
Row Count: 725,027
I/O cost: 6.73
CPU cost: 0.39
Number of executes: 2
Cost: 3%
Estimated row count: 723,244


Plan 2
I created a covering index. Completes in 1.72 seconds. Uses the covering index but performs an index scan.
Physical operation: Index Scan
Row Count: 725,027
I/O cost: 3.09
CPU cost: 0.79
Number of executes: 1
Cost: 11%
Estimated row count: 723,244



Plan 3
I used 'set forceplan'. Completes in 2.31 seconds. Uses the covering index. Performs an Index Seek.
Physical operation: Index Seek
Row Count: 20,215
I/O cost: 0.00320
CPU cost: 0.000080
Number of executes: 10449
Cost: 22%
Estimated row count: 1


Plan 3 performs a seek, I/O and CPU is good BUT the number of executes is too high. Reads are high.

Would like to know which plan is ideal with regard to this table?


Thank you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Be the first to answer this question! Click on the 'Post Reply' button below.
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 12:59 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
Copyright (c) 2006-2008 SQL Recipes

1 2 3 4 5 6 7 8