I’ve got a question about the SQL statement generating by projections when there’s a reference involved. It’s heavily simplified from TransportTaskLinesList.projection:
@Override
entity TransportTaskLines using TransportTaskLine {
crud = Read, Update, Delete;
attribute PartNo Text {
editable = [false];
}
...
reference InventoryPartRef(FromContract, PartNo) to InventoryPart(Contract, PartNo);
}
When we use this, the generate select statement is going to look like this (again heavily simplified:
SELECT A0.transport_task_status_db A0_transport_task_status_db
....
FROM (SELECT A.*
FROM (SELECT TRANSPORT_TASK_STATUS_DB transport_task_status_db,
order_type_db order_type_db,
transport_task_id transport_task_id
...
FROM TRANSPORT_TASK_LINE
WHERE (objid IN
(SELECT column_value
FROM TABLE(Transport_Task_Lines_Handling_SVC.Rd_Get_Transport_Task_Lines(....))))) A) A0
LEFT OUTER JOIN (SELECT AA1.*
FROM (SELECT description_in_use description_in_use,
NULL objgrants,
contract contract,
'InventoryPart' luname,
'CONTRACT=' || contract || '^' ||
'PART_NO=' || part_no || '^' keyref,
part_no part_no,
contract objsite
FROM INVENTORY_PART) AA1) A1
ON ((A0.from_contract = A1.contract AND A0.part_no = A1.part_no))
LEFT OUTER JOIN (SELECT AA2.*
FROM (SELECT description description,
NULL objgrants,
'ConditionCode' luname,
'CONDITION_CODE=' || condition_code || '^' keyref,
condition_code condition_code
FROM CONDITION_CODE) AA2) A2
ON ((A0.condition_code = A2.condition_code))
ORDER BY A0.transport_task_id ASC, A0.line_no ASC
FETCH FIRST 25 ROWS ONLY
You can see two LEFT OUTER JOINS, but in this case, this is probably not what we want. There’s always an InventoryPart, it could be a simple INNER JOIN.
This would be a lot nicer regarding the performance, more than 100 times faster in our case.
I understand that in same cases, a reference is optional an outer join is what we need, but if the related entity is a parent entity, we can use an inner join and we would get a better performance across I don’t know how many projections.
Is there an option I missed or something to change this behaviour?
I noticed this in 24R2.