Problem/Motivation
While investigating performance issues on a large site using the backlinks_index module, I noticed that the batch process queries all nodes regardless of the allowed bundles configured in the module settings. This occurs in two places:
On large-scale sites, this results in heavy and unnecessary database load since all nodes are being fetched, even if only specific bundles are configured to be indexed.
In addition, the truncateBacklinks() method updates all entries in the node_field_data table instead of limiting the update to rows where backlinks = 1. This can lead to unnecessary write operations on the entire table.
Proposed resolution
Batch processing improvement:
Use the $sandbox to pass through the filtered node IDs (based on allowed bundles) and iterate through those. This avoids querying the entire node table during every batch step.
Truncate optimization:
Before running the update, check if there are rows with backlinks = 1. Add a condition to the query so it only updates those specific rows, minimizing the performance impact.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3543687-2.patch | 3.13 KB | aurora.luzzardi |
Issue fork backlinks_index-3543687
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
Comment #2
aurora.luzzardiHere a patch with the proposed solution for version 1.1.2
Comment #3
aurora.luzzardiComment #7
matej.lehotsky commentedComment #8
matej.lehotsky commentedComment #10
matej.lehotsky commented