×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Query Efficiency

Query Efficiency

Query Efficiency

(OP)
Consider the following 2 querries:
_________________________________
select * from List_A A,List_B B
where  A.ID = 100
and    B.ID = A.ID
_________________________________

AND
_________________________________
select * from List_A A,List_B B
where  A.ID = 100
and    B.ID = 100
_________________________________

Both List_A and List_B tables have an index
on the ID column, and both tables are very large!
The environment is UDB.

Which query is more efficient? Please give valid reasons!

RE: Query Efficiency

Normally I'd say the second one is more efficient, but nearly every dbms will transform the first one into this query: "where A.id=100 and B.id=A.id and B.id=100"

The second one is better because on table List_B you only have one access to the index (when doing B.id=100). After filtering both tables the dbms will have two temp file with the info, then it will do the join between the temp files.
If you don't filter table List_B, when doing the join the dbms will have one access to List_B index for every List_A row! (well, this isn't exact, but you'll have more than one access)

RE: Query Efficiency

(OP)
makes sense, thanks:)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close