I have a T-SQL query that is causing performance issues. Its short, but the part that seems to be causing the problem is just LEFT JOIN.
This can be resolved by removing the left join and using the subquery in select, however this seems unsatisfactory to me, because I cannot understand why one works fast and not the other.
There is not much data, and there are keys / indexes in all columns of the connection. Only I was interested to know about the statistics of the database and whether they affect performance.
For example ( Nb is just a simplification of a much more complex request
SLOW
SELECT A.1,A.2,B.3 FROM A LEFT JOIN B ON A.ID = B.ID ...
QUICKLY
SELECT A.1, A.2, (SELECT B.3 FROM B WHERE B.ID = A.ID) FROM A