perf(db): optimize D1 indexes to eliminate full table scans (#214)

* perf(db): optimize D1 indexes to eliminate full table scans

- Add composite indexes to ec_* tables for common query patterns
- Replace single-column indexes with (deleted_at, updated_at, id) composite
- Add (deleted_at, status) index for count queries
- Add (deleted_at, created_at, id) index for chronological ordering
- Optimize comment counting with partial indexes per status
- Rewrite countByStatus() to use parallel WHERE queries instead of GROUP BY

Fixes #131

* chore: add changeset for D1 index optimization

* style: wrap changeset description for formatting compliance
This commit is contained in:
saram ali
2026-04-04 12:17:56 +05:00
committed by GitHub
parent 5b29819caf
commit e9a6f7ac3c
4 changed files with 177 additions and 48 deletions

View File

@@ -0,0 +1,8 @@
---
"emdash": patch
---
Optimizes D1 database indexes to eliminate full table scans in admin panel. Adds
composite indexes on ec_\* content tables for common query patterns (deleted_at +
updated_at/created_at + id) and rewrites comment counting to use partial indexes.
Reduces D1 row reads by 90%+ for dashboard operations.