Karaka-Management / phpOMS

PHP Framework
Other
2 stars 0 forks source link

hasMany relations should not be solved per object but after knowing all object IDs to reduce the query building and query execution. #332

Closed spl1nes closed 7 months ago

spl1nes commented 11 months ago

In the following example (QA Dashboard).

First a single query is created for questions. However, this triggers various sub-queries for every answer. A better solution would be:

  1. First make the normal request
  2. Make a subquery which uses IN (...) with all the IDs from 1.
  3. Now create the objects from 2 and add them to the elements of 1.

Image

spl1nes commented 11 months ago

The problem with solving this is that in a many-to-many relationship a relation table is used BUT the relation data is not available in the returned object; meaning after retrieving the object it cannot get assigned to the correct parent object.

Other relation types are easy because either the parent or child object contain the relation info.

spl1nes commented 7 months ago

Done