In my Oracle universe I have four tables A, B, C and D. Normal joins A-B, B-C, C-D, and shortcut join D-A.
If I make a query 1 with the two objects:
D.column and A.column,
the shortcut join D-A appears in the where clause as expected.
If I make a query 2 with the three objects:
C. column, D.column and A.column,
the joins A-B, B-C and C-D appear, instead of C-D and D-A that I thought would be used. Am I wrong in thinking that it should have used my shortcut join to avoid using the extra join in the path?
(If I try and tweak it by changing the A-B join to also being a shortcut join, to see if that could make query 2 take the path I wanted, these three objects:
C. column, D.column and A.column,
give me the joins C-D and thus return a Cartesian product.)
Do I misunderstand the concept of shortcut joins, is this intended functionality?
FYI: no contexts here, using Oracle and BOXI 3.1 SP6.
Parameter SHORTCUT_BEHAVIOR = Successive
Shortcut joins will be used if they eliminate joins. In you first scenario, the base SQL would be A-B, B-C, C-D. There are no result objects from B or C, so those tables can be eliminated from the query path, meaning the shortcut from A-D can then be used because all of the extra joins can be removed (A-B, B-C, and C-D).
In your second scenario you have objects from A, C, and D. In this case, the join from C-D cannot be dropped because you reference objects from table C. In this case, since all of the affected joins cannot be dropped, the shortcut is not a candidate.
I wrote a blog post several years ago that is all about shortcuts. I’m not sure I covered the specific scenario (and if not it would be a good follow-up) but you can read it here:
I had actually already read your post, but still felt (and feel) a bit confused. In my scenario 2, table B would be eliminated if the shortcut join was used, that’s why I expected the query to take the shortcut path. But you are saying that since all the joins from the normal join path wouldn’t be dropped, none will be dropped?
All of the joins covered by the shortcut, yes. In the scenario you outlined, you have to be able to drop both B and C in order to use the shortcut, not just one.
Shortcut joins are not a loop resolution method. If your universe is not working before shortcuts, it won’t be working after either. They’re only added as a performance measure.
If you haven’t read my blog post linked earlier, it might help. Good luck!