June 3, 2005 at 6:23 am
I need help on the following queries, can anyone tell me what hypothetical execution plans these queries do??
(1)SELECT *
FROM TABLE;
(2)SELECT COUNT(*)
FROM TABLE;
(3)SELECT S_SUPPKEY
FROM TABLE;
(4)SELECT *
FROM TABLE
WHERE S_NAME = 'User';
June 3, 2005 at 6:25 am
Without knowing HOW you set up the table (indexes, row count, etc..) it is impossible for us to even GUESS.
However, IF you hit CTRL+L inside QA it will provide you an "estimated execution plan" OR CTRL+K and RUN the query it will provide the ACTUAL plan used
Good Hunting!
AJ Ahrens
webmaster@kritter.net
June 3, 2005 at 6:33 am
Looking at my crystal I see:
1) Table scan or Clustered Index Scan
2) Scan of the narrowest index SQL Server can find. If no index present, I think table scan
3) Index scan or clustered index scan.
4) Index Seek or Clustered Index Seek.
But as AJ pointed out, you can easily check this out yourself.
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
June 3, 2005 at 6:35 am
Actually, I can answer for #2.
If there's an index on the table on a column that is not nullable, then the query will scan that index to count all rows.
If not suitable index is found, then a table scan will be performed.
June 3, 2005 at 6:36 am
Damn, got beaten again .
June 3, 2005 at 6:41 am
Sorry,
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
June 3, 2005 at 6:44 am
wow... the replies are fast!
thanks alot guys, appreciated the helps.. will look tru the Ctrl + K
June 3, 2005 at 6:45 am
You're welcome!
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
June 3, 2005 at 6:47 am
3 replies in 10 minutes... I've seen faster in this board .
June 3, 2005 at 6:52 am
What do you expect on a Friday afternoon?
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
June 3, 2005 at 6:57 am
5 replies in 2 minutes... we are less busy that time of the week .
June 3, 2005 at 7:04 am
heh, its actually 8.51pm at my place.. doing my assignment..
actually... where do i press the ctrl + k at?? what QA??
thanks all..
June 3, 2005 at 7:08 am
QA = Query Analyzer
Paste the 4 queries in the window, then hit ctrl-k (or go in the query menu, and select show execution plan).
Then run the queries (F5 or the green play button).
Then under the results you'll see the execution plan tab.
June 3, 2005 at 7:09 am
where can I find the QA?
June 3, 2005 at 7:12 am
Start / All programs / Sql Server / Query Analyser
You'll be prompted to login to a server.. select the server and enter login info as required. Then follow the previous steps.
Viewing 15 posts - 1 through 15 (of 17 total)
You must be logged in to reply to this topic. Login to reply