question

Maxmarathon avatar image
Maxmarathon asked

Using exists in statements sql

Hello. I've got a problem with a sql statement used in two tables joined with exixts. It's possible that the statement "exist" exlude the use of indexes created on the two tables?

The statement sql above, works in IBM Host3270. The sql release is v8.

Thank.

sql-server-2008
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

TG avatar image TG commented ·
Please post the actual statement and please specify the "problem" that you're having?
0 Likes 0 ·
graz avatar image graz ♦ commented ·
And the version you're using. This is tagged with 2008 but v8 is SQL Server 2000. Is this SQL Server?
0 Likes 0 ·
TG avatar image
TG answered

use of the keyword EXISTS does not prevent the use of available indexes.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Michael Haren avatar image
Michael Haren answered

EXISTS absolutely uses indexes--it would be completely unusable without them for any real database.

This article describes a related topic--how COUNT(*) chooses which index to use. Nice reading if you're interested in the inner workings.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.