Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why table scan?
Message
 
To
20/02/2008 02:45:52
Walter Meester
HoogkarspelNetherlands
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01293823
Message ID:
01294153
Views:
20
>Hi Boris,
>
>First of all your example below of course does not contain any records. The Query plan might be very different depending on the data statistics.
>
>What I think is happening here is that in the first query you only check for the existance of a matching record in Test2. SQL server is smarter than VFP in the way it uses indexes. Since the information can be retrieve from the index alone, it does not have to touch the test2 table at all.
>
>In the second query, you request the actual field contents of test2, and therefor SQL server has to retrieve the actual information from the table. Whether SQL server is doing a Table scan or index seek, really is depended on the calculated cost (SQL server has a cost base optimizer, VFP has a rule base optimizer). Since you example does not contain any records, it is doing a table scan. If these table contain thousands of records, SQL server is examining the query, the keys and their selectivity and draws a execution plan that is the most efficient.
>
>
>Walter,

Thank you Walter,
although this is just an example I have the same situation with real data. And believe me both tables have records.
What surprises me is that if I make that index to be PRIMARY I have INDEX SEEK no matter what I use.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform