mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
schema: add composite index (is_published, year DESC) + fix stale migration 005
- Add idx_theses_pub_year composite index on theses(is_published, year DESC) to schema.sql; replaces the need for the query planner to pick between the two separate idx_theses_published / idx_theses_year indexes and sort with a temp B-tree. Every public query filters on is_published=1 and orders/filters by year, so this covering index eliminates the sort pass for those queries. - Create storage/migrations/006_add_composite_index.sql and apply to both posterg.db and test.db. - Fix storage/migrations/005_add_banner.sql: the view recreation in that file still referenced the pre-migration-001 table/column names (thesis_keywords, keywords.keyword). Updated to use thesis_tags / tags tg to match the canonical schema.sql. The live DB was unaffected (migration 001 ran before 005), but the file was misleading and would fail if ever re-run from scratch.
This commit is contained in:
@@ -306,6 +306,7 @@ INSERT OR IGNORE INTO pages (slug, title, content) VALUES
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_theses_year ON theses(year);
|
||||
CREATE INDEX IF NOT EXISTS idx_theses_published ON theses(is_published);
|
||||
CREATE INDEX IF NOT EXISTS idx_theses_pub_year ON theses(is_published, year DESC);
|
||||
CREATE INDEX IF NOT EXISTS idx_theses_identifier ON theses(identifier);
|
||||
CREATE INDEX IF NOT EXISTS idx_theses_orientation ON theses(orientation_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_theses_ap_program ON theses(ap_program_id);
|
||||
|
||||
Reference in New Issue
Block a user