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
SLO-106 Added index on status field for posts table #20181
base: main
Are you sure you want to change the base?
Conversation
It looks like this PR contains a migration 👀 General requirements
Schema changes
Data changes
|
1987efe
to
a279d05
Compare
e50851c
to
016773c
Compare
@vershwal Thanks for creating this! Can you attach EXPLAIN ANALYZE output of this query before and after the change so we can understand the impact it's having on the query analyzer? Can you also test this before/after on a database in staging that's having this problem and share what improvement this is making for the customer as experienced from the browser? |
Query 1
Current behavior:-
After adding index:-
The estimated cost has decreased |
Query 2
Current behavior:-
After adding index
The estimated cost has decreased from |
const {createNonTransactionalMigration} = require('../../utils'); | ||
const {addIndex, dropIndex} = require('../../../schema/commands'); | ||
|
||
module.exports = createNonTransactionalMigration( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simplify this by using createAddIndexMigration
, just like
Line 3 in 842290c
module.exports = createAddIndexMigration('members_created_events', ['attribution_id']); |
There are slow queries on the posts table that take up to 5 minutes to browse posts for customers with a large number of posts.
Sentry link: https://ghost-foundation.sentry.io/performance/?isDefaultQuery=false&metricSearchSetting=metricsOnly&project=1879038&query=transaction%3A%22GET+%2Fghost%2Fapi%2Fadmin%2Fposts%2F%22&statsPeriod=7d&utc=true
There are two slow queries and an index on
[status, type]
will improve the performance of both of these queries.