Consider a join A LEFT JOIN B ON A.id = B.a_id:
B.a_idis nullable -- most but not allBrecords point to anArecord.Acan, at most, only have one matchingBrecord (business logic).- Not all
Arecords have a match inB.
Is there a way to tell MSSQL that there will never be more than one A:B match, thus allowing it to shortcut the join once a match is found for a given A record?
I would think that such an optimization could happen if B.a_id had a unique index, but that's not possible since it's nullable.
Complicating the issue: A and B are in different databases (same MSSQL instance).
If it matters, I'm using SQL Server 2008 R2.
Aucun commentaire:
Enregistrer un commentaire