Problem/Motivation

The unnecessary use of Cartesian joins leads to particularly slow queries with large populated tables, where each row of each table might be matched with every row of every other table during the execution the query. In particular, this might occur when a full scan of the join happens looking for something that _does not_ occur in the tables (looking for an entity type that is not tracked, for example).

Two known locations performing Cartesian joins are:

There may be others.

Steps to reproduce

Perform the queries separately, and see that the set of columns returned contains the columns of all tables under the Cartesian join.

Proposed resolution

Rework process and/or queries to avoid Cartesian joins. Given the two queries in question are related exclusively to the existence of rows matching particular conditions, we could move to perform multiple individual queries, and return the disjunction of all of them. Alternatively, reworking the queries to do the separate queries UNION ALL'd together might do the trick in one.

Remaining tasks

- get code into MR
- review
- merge
- release

User interface changes

None.

API changes

None.

Data model changes

None.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

adam-vessey created an issue. See original summary.

adam-vessey’s picture

Issue summary: View changes
adam-vessey’s picture

Assigned: adam-vessey » Unassigned
Status: Active » Needs review
adam-vessey’s picture

Issue summary: View changes
bibliophileaxe’s picture

Status: Needs review » Reviewed & tested by the community

We have been using this patch in production and it works and has increased performance noticeably.

joecorall made their first commit to this issue’s fork.

joecorall’s picture

Thank you!

joecorall’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.