-- 041: Add index on thesis_languages(language_id) for contenus page performance.
--
-- The contenus page queries getAllLanguagesWithCount() and searchLanguages() join
-- languages → thesis_languages on language_id.  SQLite's PRIMARY KEY on
-- (thesis_id, language_id) cannot optimize a lookup by language_id alone, so
-- it builds an AUTOMATIC COVERING INDEX per query.  This persisted index
-- removes that overhead.
--
-- Also adds a covering index on tags(deleted_at, name) to accelerate
-- getAllTagsWithCount() and searchTags() ORDER BY clauses (avoiding temp B-tree).

CREATE INDEX IF NOT EXISTS idx_thesis_languages_language
    ON thesis_languages(language_id);

CREATE INDEX IF NOT EXISTS idx_tags_deleted_name
    ON tags(deleted_at, name);
