~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
refactor(journal): drop redundant ``journals`` indexes (#3571)
LearningCircuit054d93843ede
diff --git a/src/local_deep_research/database/migrations/versions/0006_journal_quality_system.py b/src/local_deep_research/database/migrations/versions/0006_journal_quality_system.pyindex bc36a22e15..033558bdaf 100644--- a/src/local_deep_research/database/migrations/versions/0006_journal_quality_system.py+++ b/src/local_deep_research/database/migrations/versions/0006_journal_quality_system.py@@ -87,7 +87,11 @@ _JOURNAL_COLUMNS = []_JOURNAL_INDEXES = [- ("ix_journals_name_lower", ["name_lower"]),+ # NB: no separate index on ``name_lower``. The+ # ``uq_journals_name_lower`` UNIQUE constraint created below+ # provides a backing index, and a second non-unique index on the+ # same column would be pure duplication — two B-trees maintained+ # per INSERT/UPDATE for no query benefit.("ix_journals_quality_model", ["quality_model"]),]diff --git a/src/local_deep_research/database/models/journal.py b/src/local_deep_research/database/models/journal.pyindex a55d583a10..3ff11064af 100644--- a/src/local_deep_research/database/models/journal.py+++ b/src/local_deep_research/database/models/journal.py@@ -33,27 +33,16 @@ class Journal(Base):)# --- Identity ---- # Cleaned/normalized journal name.- # KNOWN-DEFERRED: index=True is redundant with unique=True (UNIQUE- # creates a backing index). Kept for now to match the migration- # 0001 baseline which declared both; removing requires a follow-up- # migration and a golden-master schema test update. Post-merge cleanup.- name = Column(String(255), nullable=False, unique=True, index=True)- # Lower-cased copy of ``name`` for indexed case-insensitive lookups- # on the citation-save hot path. Without this column callers have- # to do ``func.lower(Journal.name)`` which defeats the ``name``- # index and forces a full-table scan. UNIQUE declared via- # ``__table_args__`` below with explicit name ``uq_journals_name_lower``- # so it matches the migration and doesn't drift in the schema-- # parity test (`test_migrations_produce_schema_matching_models``).- #- # KNOWN-DEFERRED: index=True produces ix_journals_name_lower; the- # UNIQUE constraint in __table_args__ produces uq_journals_name_lower.- # On SQLite these are two backing indexes over the same column; the- # non-unique one is redundant. Post-merge cleanup paired with a- # follow-up migration. Keeping both today avoids an extra migration- # step in this PR.- name_lower = Column(String(255), nullable=True, index=True)+ # Cleaned/normalized journal name. UNIQUE provides the backing+ # index SQLite needs for the exact-name lookup path; a separate+ # non-unique index would be pure duplication.+ name = Column(String(255), nullable=False, unique=True)+ # Lower-cased NFKC-normalized copy of ``name`` for indexed case-+ # insensitive lookups on the citation-save hot path. The UNIQUE+ # constraint in ``__table_args__`` provides the backing index; a+ # separate non-unique ``index=True`` would be a second redundant+ # B-tree on the same column.+ name_lower = Column(String(255), nullable=True)# --- LLM cache payload ---# Composite quality score (1-10). See constants.VALID_QUALITY_SCORES.diff --git a/tests/database/test_migration_0006.py b/tests/database/test_migration_0006.pyindex db4ed8b13c..66e50d93af 100644--- a/tests/database/test_migration_0006.py+++ b/tests/database/test_migration_0006.py@@ -311,9 +311,22 @@ class TestMigration0006JournalsColumns:assert "quality_model" in colsdef test_indexes_present(self, fully_migrated_engine):+ """0006 creates ``ix_journals_quality_model``. It does NOT+ create a non-unique index on ``name_lower``: the+ ``uq_journals_name_lower`` UNIQUE constraint already provides+ the backing index and a second B-tree on the same column+ would be pure write-amplification.+ """indexes = _get_indexes_by_name(fully_migrated_engine, "journals")- assert "ix_journals_name_lower" in indexesassert "ix_journals_quality_model" in indexes+ assert "ix_journals_name_lower" not in indexes, (+ "ix_journals_name_lower is redundant with uq_journals_name_lower"+ " — must not be created by 0006."+ )+ assert "ix_journals_name" not in indexes, (+ "ix_journals_name is redundant with UNIQUE on Journal.name"+ " — must not be created via model.create_all() either."+ )def test_name_lower_backfill_preserves_diacritics(self, migrated_to_0005_engine