mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-07 03:29: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:
@@ -38,7 +38,7 @@ SELECT
|
||||
GROUP_CONCAT(DISTINCT CASE WHEN ts.role = 'lecteur' THEN s.name END) as jury_lecteurs,
|
||||
GROUP_CONCAT(DISTINCT l.name) as languages,
|
||||
GROUP_CONCAT(DISTINCT fmt.name) as formats,
|
||||
GROUP_CONCAT(DISTINCT k.keyword) as keywords
|
||||
GROUP_CONCAT(DISTINCT tg.name) as keywords
|
||||
FROM theses t
|
||||
LEFT JOIN orientations o ON t.orientation_id = o.id
|
||||
LEFT JOIN ap_programs ap ON t.ap_program_id = ap.id
|
||||
@@ -53,8 +53,8 @@ LEFT JOIN thesis_languages tl ON t.id = tl.thesis_id
|
||||
LEFT JOIN languages l ON tl.language_id = l.id
|
||||
LEFT JOIN thesis_formats tf ON t.id = tf.thesis_id
|
||||
LEFT JOIN format_types fmt ON tf.format_id = fmt.id
|
||||
LEFT JOIN thesis_keywords tk ON t.id = tk.thesis_id
|
||||
LEFT JOIN keywords k ON tk.keyword_id = k.id
|
||||
LEFT JOIN thesis_tags tt ON t.id = tt.thesis_id
|
||||
LEFT JOIN tags tg ON tt.tag_id = tg.id
|
||||
GROUP BY t.id;
|
||||
|
||||
-- Recreate public view
|
||||
|
||||
Reference in New Issue
Block a user