Ghost/ghost/core/test/utils
Kevin Ansfield bd93bf0dea Optimised email stats aggregation query for typical column usage
ref https://linear.app/tryghost/issue/ENG-790/remove-use-of-sub-queries-in-email-analytics

- the `delivered_at` column is typically entirely/nearly entirely filled with values meaning the `IS NOT NULL` query matches a huge number of rows that MySQL has to fetch from the index to count
- using `IS NULL` switches that behaviour around as it will now match very few rows which has been shown in testing to be considerably quicker
- after switching to `IS NULL` the query returns an "undelivered" count rather than a "delivered" count, in order to keep the rest of the system behaviour the same we can calculate the delivered count by subtracting the query result from the total number of emails sent which we can fetch using a very fast primary key lookup query on the `emails` table
2024-04-03 16:27:23 +01:00
..
agents
fixtures Optimised email stats aggregation query for typical column usage 2024-04-03 16:27:23 +01:00
mocks
admin-utils.js
api.js
assertions.js
batch-email-utils.js
configUtils.js
db-utils.js
e2e-framework-mock-manager.js
e2e-framework.js
e2e-utils.js
fixture-utils.js
index.js
mocha-retry-reporter.js
overrides.js
redirects.js
stripe-mocker.js
url-service-utils.js
urlUtils.js