Problem/Motivation

On PostgreSQL, every insert, update and upsert query calls Schema::queryTableInformation() to find the blob and serial columns of the target table. Each call runs a catalog query. A request pays one catalog query per table it writes to, on every request.

Proposed resolution

Add a TableInformationLoader that collects the information for all tables of a connection with one catalog query. Cache the result in the bootstrap cache bin. Delete the cached information on every schema change.

Each connection owns one loader, available through Connection::tableInformation(). The insert, update and upsert queries and the schema object use it. Temporary tables and tables created after the load are introspected individually. The information collected during a transaction is not persisted, because PostgreSQL DDL is transactional.

The pgsql.table_information_prewarmer service prewarms the cache of the default connection.

Remaining tasks

Review.

API changes

New public method Connection::tableInformation() on the pgsql driver. New service pgsql.table_information_prewarmer. Schema::queryTableInformation() delegates to the loader.

Data model changes

None.

For the committer

The changes to the .gitlab-ci.yml file need to be removed before merging!

Issue fork drupal-3615649

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

daffie created an issue. See original summary.

daffie’s picture

Status: Active » Needs review

The CI pipeline failures for PostgreSQL are not related to the changes in the PR.
Ready for a review.

daffie’s picture

Issue summary: View changes
daffie’s picture

Disclosure: I have used AI on the PR, the IS and the CR.

smustgrave’s picture

Status: Needs review » Needs work

1 comment on the MR.

daffie’s picture

Status: Needs work » Needs review

Rebased the PR and responded to remark from @smustgrave.