Skip to content

Reduce over-fetching in Bugscache queries#9569

Open
camd wants to merge 2 commits into
masterfrom
camd/bugscache-summary-gin-trgm-index
Open

Reduce over-fetching in Bugscache queries#9569
camd wants to merge 2 commits into
masterfrom
camd/bugscache-summary-gin-trgm-index

Conversation

@camd
Copy link
Copy Markdown
Collaborator

@camd camd commented Jun 1, 2026

Bugscache.search() and the create_bug endpoint loaded full Bugscache
rows when only a subset of columns is actually used:

  • search(): defer modified and processed_update via .only(), since
    serialize() excludes them anyway. Remove the dead jobmap entry from
    the serialize() exclude list (a reverse relation model_to_dict never
    iterates).
  • create_bug: resolve the existing bug id with values_list() instead of
    fetching the whole row, restrict the summary fallback query with
    .only(), and limit the linking save() to the two changed columns via
    update_fields.

Add tests covering the create_bug internal-id resolution paths.

camd added 2 commits May 25, 2026 10:30
Bugscache.search() and the create_bug endpoint loaded full Bugscache
rows when only a subset of columns is actually used:

- search(): defer `modified` and `processed_update` via .only(), since
  serialize() excludes them anyway. Remove the dead `jobmap` entry from
  the serialize() exclude list (a reverse relation model_to_dict never
  iterates).
- create_bug: resolve the existing bug id with values_list() instead of
  fetching the whole row, restrict the summary fallback query with
  .only(), and limit the linking save() to the two changed columns via
  update_fields.

Add tests covering the create_bug internal-id resolution paths.
Bugscache.search() filters with `summary ILIKE '%term%'` and orders by
trigram similarity. The existing btree index on summary cannot serve
substring or similarity matching, so every search does a sequential scan
of the bugscache table.

Add a GIN trigram index (gin_trgm_ops) on summary so those searches can
use an index scan. Built CONCURRENTLY (non-atomic migration) to avoid a
write lock on the table. The pg_trgm extension is already enabled
(migration 0031).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant