perf(db): add published_at composite index for frontend listing queries#333
Merged
ascorbic merged 2 commits intoemdash-cms:mainfrom Apr 11, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: beefc8a The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/blocks
@emdash-cms/cloudflare
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
16 tasks
Contributor
Overlapping PRsThis PR modifies files that are also changed by other open PRs: This may cause merge conflicts or duplicated work. A maintainer will coordinate. |
16 tasks
Collaborator
|
Could you fix the conflicts? It'd be good to get this in |
Adds idx_{table}_deleted_published_id on (deleted_at, published_at DESC, id DESC)
to all ec_* content tables. The frontend listing query orders by published_at but
no existing index covers it, causing full table scans on D1 (~15,883 rows per query
on a 16k post site).
Also registers migration 033 (optimize_content_indexes) which existed on disk but
was missing from the StaticMigrationProvider.
Fixes emdash-cms#277
bd3e886 to
beefc8a
Compare
Contributor
Author
|
@ascorbic rebased on main (beefc8a) and resolved conflicts:
All 2252 tests pass locally after the rebase. Let me know if there's anything else you'd like me to tweak. |
fmhall
pushed a commit
to fmhall/emdash
that referenced
this pull request
Apr 13, 2026
…es (emdash-cms#333) * perf(db): add published_at composite index for frontend listing queries Adds idx_{table}_deleted_published_id on (deleted_at, published_at DESC, id DESC) to all ec_* content tables. The frontend listing query orders by published_at but no existing index covers it, causing full table scans on D1 (~15,883 rows per query on a 16k post site). Also registers migration 033 (optimize_content_indexes) which existed on disk but was missing from the StaticMigrationProvider. Fixes emdash-cms#277 * docs: add changeset for published_at index --------- Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
Closes #277
Adds a composite index
(deleted_at, published_at DESC, id DESC)to allec_*content tables. The frontend listing query orders bypublished_at, but no existing index covers it. On a site with ~16k posts this causes ~15,883 rows read per query (full table scan).Also registers migration 033 (
optimize_content_indexes) which existed on disk but was missing from theStaticMigrationProvider.Type of change
Checklist
pnpm typecheckpassespnpm --silent lint:json | jq '.diagnostics | length'returns 0pnpm testpasses (or targeted tests for my change)pnpm formathas been runAI-generated code disclosure
This contribution was developed with AI assistance (Codex).