Skip to main content
Question

Inner join when referencing connecting entities in projection

  • February 20, 2025
  • 3 replies
  • 45 views

Forum|alt.badge.img+4
  • Do Gooder (Customer)
  • 12 replies

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.

3 replies

PhillBronson
Hero (Customer)
Forum|alt.badge.img+10
  • Hero (Customer)
  • 112 replies
  • February 20, 2025

@Remo good question


Forum|alt.badge.img+4
  • Sidekick (Customer)
  • 5 replies
  • February 26, 2025

Hi Remo

We are facing the same problem i.e. with transport tasks that run in a timeout due to left outer joins to inventory parts (that always exist for a transport task). 

Would you create an idea for this topic and I would upvote it? If not, I will create an idea, this is a no go for us, functionality not working.

Many thanks for a reply.

BR, Daniel


Forum|alt.badge.img+4
  • Author
  • Do Gooder (Customer)
  • 12 replies
  • February 26, 2025

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings