From d0a27fe0957000e88999f662e5a731e6b87f8a09 Mon Sep 17 00:00:00 2001 From: elpatron Date: Tue, 18 Mar 2025 14:01:08 +0100 Subject: [PATCH] =?UTF-8?q?Performance:=20Indizes=20f=C3=BCr=20alle=20Such?= =?UTF-8?q?felder=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index 471228d..b09ddca 100644 --- a/app.py +++ b/app.py @@ -54,12 +54,18 @@ def init_db(): ) ''') - # Erstelle Indizes für häufig durchsuchte Spalten - c.execute('CREATE INDEX IF NOT EXISTS idx_name ON customers(name)') - c.execute('CREATE INDEX IF NOT EXISTS idx_ort ON customers(ort)') - c.execute('CREATE INDEX IF NOT EXISTS idx_nummer ON customers(nummer)') - c.execute('CREATE INDEX IF NOT EXISTS idx_telefon ON customers(telefon)') - c.execute('CREATE INDEX IF NOT EXISTS idx_email ON customers(email)') + # Erstelle Indizes für alle Suchfelder + c.execute('CREATE INDEX IF NOT EXISTS idx_customers_nummer ON customers(nummer)') + c.execute('CREATE INDEX IF NOT EXISTS idx_customers_name ON customers(name)') + c.execute('CREATE INDEX IF NOT EXISTS idx_customers_strasse ON customers(strasse)') + c.execute('CREATE INDEX IF NOT EXISTS idx_customers_plz ON customers(plz)') + c.execute('CREATE INDEX IF NOT EXISTS idx_customers_ort ON customers(ort)') + c.execute('CREATE INDEX IF NOT EXISTS idx_customers_telefon ON customers(telefon)') + c.execute('CREATE INDEX IF NOT EXISTS idx_customers_mobil ON customers(mobil)') + c.execute('CREATE INDEX IF NOT EXISTS idx_customers_email ON customers(email)') + + # Erstelle einen zusammengesetzten Index für die häufigste Suchkombination + c.execute('CREATE INDEX IF NOT EXISTS idx_customers_name_ort ON customers(name, ort)') conn.commit() conn.close()