Left join on one or the other column without table-scanning
0
votes
1
answer
3439
views
I have this huge sql with a lot of left joins. Mostly on the tables primary key, so no problem. On one table though, my key could exist in either one column or the other.
Syntax-wise that is no problem:
LEFT JOIN table2 blk ON (t.rid=blk.transact OR t.rid=blk.transactchild)
I have created two indices on table2, one for each of the keys, but my Sybase ASE 15.7 decides to table scan in stead. So I tried creating a single index with both of the keys and forcing it in the join, but that didn't help on performance. Showplan indicates, that the index is being used, but a scan takes forever. Is there a better way to join on either one or the other column?
Asked by scaarup
Nov 1, 2015, 08:39 PM
Last activity: Jul 8, 2017, 04:26 PM
Last activity: Jul 8, 2017, 04:26 PM