Open
Description
Currently relations are expressed via new PgSelect and then at optimize the join can be made (this allows you to forbid joining if you want).
However, when we want to order/condition on a relational poly table (see #2593) we also want to do a relational join.
Currently we can't tell that these are equivalent, and it results in two separate joins. Would be better if we could detect that the join would be equivalent to a relational join and do that instead during optimize - then we can use that relational join in other places without duplication.
select
__relational_topics__."topic_item_id"::text as "0",
- __relational_items__."id"::text as "1"
+ __relational_items_by_my_topic_item_id__."id"::text as "1"
from "polymorphic"."relational_topics" as __relational_topics__
left outer join "polymorphic"."relational_items" as __relational_items_by_my_topic_item_id__
on (__relational_topics__."topic_item_id" = __relational_items_by_my_topic_item_id__."id")
-left outer join "polymorphic"."relational_items" as __relational_items__
-on (
-/* WHERE becoming ON */ (
- __relational_items__."id" = __relational_topics__."topic_item_id"
-))
where (
__relational_items_by_my_topic_item_id__."archived_at" is null
)
order by __relational_items_by_my_topic_item_id__."created_at" asc, __relational_topics__."topic_item_id" asc;
Metadata
Metadata
Assignees
Type
Projects
Status
🌳 Triage