Add Confluence Page multi-columns index on lastVisitedAt #3418
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR resolves #3415.
This PR introduces a new multicolumns index for the
confluence_pages
table, intended to support the data reporting API (see #3405) in retrieving the oldest updated time.The query is
SELECT "lastUpdatedAt" FROM confluence_pages WHERE "connectorId" = X ORDER BY "lastVisitedAt" DESC LIMIT 1
. Based on PostgreSQL's documentation, a composite index is effective for optimizing both theWHERE
clause and theORDER BY
directive.This PR adds a multicolumn index on
connectorId
andlastVisitedAt
. While it's challenging to assess the index's efficiency on a very small table, by turning off sequential scans usingSET enable_seqscan = OFF;
on my local setup, I managed to execute an explain query that confirms the index is being correctly utilized.Risk
Deploy Plan
This PR requires a migration, but pretty safe since it only create an index. It's safe to deploy in production before running the migration.