Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added composite index to posts table for type,status #20437

Merged
merged 3 commits into from
Jun 24, 2024

Conversation

9larsons
Copy link
Contributor

ref https://linear.app/tryghost/issue/CFR-35

  • performance improvement intended for the content api/get helpers

The posts table is shared by posts and pages and seldom is queried for both. It makes sense to add an index on type, and from the perspective of the content API, also on status as you're almost only ever querying for published posts or published pages.

ref https://linear.app/tryghost/issue/CFR-35
- performance improvement intended for the content api/get helpers

The posts table is shared by posts and pages and seldom is queried for both. It makes sense to add an index on type, and from the perspective of the content API, also on status as you're almost only ever querying for published posts or published pages.
@9larsons 9larsons requested a review from mike182uk June 20, 2024 21:22
@github-actions github-actions bot added the migration [pull request] Includes migration for review label Jun 20, 2024
Copy link
Contributor

github-actions bot commented Jun 20, 2024

It looks like this PR contains a migration 👀
Here's the checklist for reviewing migrations:

General requirements

  • Satisfies idempotency requirement (both up() and down())
  • Does not reference models
  • Filename is in the correct format (and correctly ordered)
  • Targets the next minor version
  • All code paths have appropriate log messages
  • Uses the correct utils
  • Contains a minimal changeset
  • Does not mix DDL/DML operations

Schema changes

  • Both schema change and related migration have been implemented
  • For index changes: has been performance tested for large tables
  • For new tables/columns: fields use the appropriate predefined field lengths
  • For new tables/columns: field names follow the appropriate conventions
  • Does not drop a non-alpha table outside of a major version

Data changes

  • Mass updates/inserts are batched appropriately
  • Does not loop over large tables/datasets
  • Defends against missing or invalid data
  • For settings updates: follows the appropriate guidelines

@9larsons
Copy link
Contributor Author

Index is added in a few ms for a test set of 20k posts. This may be a bit longer for the couple biggest customers - I think the largest has ~125k posts, but all in all is very quick.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version needs bumping

we had a release while this PR was sitting so we need to make sure this runs on the next released version
@daniellockyer daniellockyer self-requested a review June 24, 2024 14:03
@9larsons 9larsons merged commit 4f6842b into main Jun 24, 2024
22 checks passed
@9larsons 9larsons deleted the add-posts-typestatus-index branch June 24, 2024 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
migration [pull request] Includes migration for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants