In SqlContentEntityStorage::loadSingleCardinalityFields(), for every row and every single-cardinality field, the code runs array_intersect_key($row, array_flip($field_columns[$field_name])) and then array_any() over the result to find a non-NULL value. $field_columns doesn't change inside the loop, so the flip and the intersection build temporary arrays rows × fields times for nothing. On entity types with many fields and bulk loads (views, migrations, search indexing) it shows up in profiles.

Checking the columns directly gives the same result, since isset() is FALSE for NULL:

array_any($field_columns[$field_name], fn ($column) => isset($row[$column]))

No behaviour change, the existing entity storage tests cover it. #3593963: Field loading can hit the MySQL 61 table join limit if there are ~60 fields reworked this method recently but didn't touch this part.

Attached patch is our 11.4.x version (explicit loop), I'll open an MR for main with array_any().

Issue fork drupal-3632309

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

bceyssens created an issue. See original summary.

bceyssens’s picture

Status: Active » Needs review