Skip to content
Advertisement

SQL: Nested Select vs Double JOIN by Performance

I have report based on a stored procedures and I need to add User name into output.

In my system TWO users can be owners of transaction.

Also, in my system User information stored in different database.

So, I see only two ways to add User name:

CASE 1

CASE 2

I’ve tried to do performance test on my local machine with 1 million of test transactions and 10 thousand of users, but results were equal.

What is the best way to do it from performance point of view and why?

The real database contains about 20 million transactions divided by 10 groups and 100 thousand of users.

Advertisement

Answer

Can you please try with this following script? This should return the same result your query is returning.

Please test the output is same as your query or not. If mismatch, just ignore this solution.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement