Skip to content

Add GIN trigram index on bugscache.summary#9555

Open
camd wants to merge 1 commit into
camd/query-optimization-bugscachefrom
camd/bugscache-summary-gin-trgm-index
Open

Add GIN trigram index on bugscache.summary#9555
camd wants to merge 1 commit into
camd/query-optimization-bugscachefrom
camd/bugscache-summary-gin-trgm-index

Conversation

@camd
Copy link
Copy Markdown
Collaborator

@camd camd commented May 25, 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.

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).
@camd camd self-assigned this May 25, 2026
@camd camd added the db-schema-changes This PR will require a Database Schema change label May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

db-schema-changes This PR will require a Database Schema change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant