Click here to Skip to main content
14,638,900 members
Rate this:
Please Sign up or sign in to vote.
See more:
It is an interview question. The interviewer did not mention too much. He just asked me:
I have two tables, They don't have primary keys. If I want to select data from the two tables.
I want to know the performance by join vs sub query.

What I have tried:

google search has clues. But they don't indicate whether primary keys.
Updated 20-Jul-17 12:53pm
PIEBALDconsult 20-Jul-17 16:28pm
To do what? Please use "Improve question" to add detail, context, examples, etc.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Google search has more than clues - it has answers[^]
I'm sorry, but if you can neither answer the question, nor determine the answer from a google search; and if you haven't got the nouse to say "I don't know the answer - I would examine the execution plan to work out the difference in performance" then I have to question how you got as far as the "interview" in the first place.

Sometimes the "right" answer is to say "I don't know ... but this is how I would find out/remind myself/look it up in the documentation"... that is the best advice I was given, so I'm passing it on to you
Member 12658724 20-Jul-17 19:23pm
So it has nothing to do with the primary keys? Join is always better than sub-query?
CHill60 21-Jul-17 16:31pm
Not always. You would need to examine the execution plan. There is an article here on CP on how to do that

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100