Hi,
i'm experiencing very slow performance when using prefetchpaths in the following scenario.
Table 'Order' has a 4-field primary key (say PKF1, PKF2, PKF3 and PKF4) and a 1 to many relation with table 'OrderLine', which has a 8-field primary key (first 4 fields match Table 'A')
Using prefetch paths to search for all orders of a particular person (Person is an indexed attribute in 'Order') and all associated OrderLines, it is very slow for persons having more than 100 orders.
My guess is, that the generated SQL isn't very optimized here.
I tried to tweak with 'DataAccessAdapter.ParameterisedPrefetchPathThreshold', but i think because of the nature of a multi-field PK, it always results in the same SQL.
This is roughly the generated statement:
SELECT *
FROM OrderLine
WHERE (OrderLine.PKF1 IN (SELECT PKF1 FROM Order Where Person=100))
AND (OrderLine.PKF2 IN (SELECT PKF2 FROM Order Where Person=100))
AND (OrderLine.PKF3 IN (SELECT PKF3 FROM Order Where Person=100))
AND (OrderLine.PKF4 IN (SELECT PKF4 FROM Order Where Person=100))
Problem is that the subqueries produce a much to big resultset.
Better was to use 'EXISTS' instead of 'IN', or even better:
SELECT *
FROM OrderLine
WHERE (OrderLine.PKF1,OrderLine.PKF2,OrderLine.PKF3,OrderLine.PKF4) IN (SELECT PKF1, PKF2, PKF3, PKF4 FROM Order Where Person=100)
which is way faster.
The generated query now takes more than a minute!
For your information: all this is done on an Oracle database.
Is there any way to improve performance in this scenario?