Add two new indexes to DB for faster querying
This commit is contained in:
parent
0cac5e806f
commit
20bdce68a3
@ -95,9 +95,21 @@ def init_database():
|
||||
def create_indexes():
|
||||
LOG.info("Try to create indexes")
|
||||
conn = sqlite3.connect(DB_NAME, timeout=300)
|
||||
LOG.info("Starting to build index: idx_date_of_start_date")
|
||||
conn.execute("""CREATE INDEX IF NOT EXISTS idx_date_of_start_date
|
||||
ON usage_stats (date(start_date, "unixepoch"))""")
|
||||
conn.commit()
|
||||
LOG.info("Created index: idx_date_of_start_date")
|
||||
LOG.info("Starting to build index: idx_end_station_id_date_of_start_date")
|
||||
conn.execute("""CREATE INDEX IF NOT EXISTS "idx_end_station_id_date_of_start_date"
|
||||
ON "usage_stats" ("end_station_id" ASC, date(start_date, "unixepoch"))""")
|
||||
conn.commit()
|
||||
LOG.info("Created index: idx_end_station_id_date_of_start_date")
|
||||
LOG.info("Starting to build index: idx_start_station_id_date_of_start_date")
|
||||
conn.execute("""CREATE INDEX IF NOT EXISTS "idx_start_station_id_date_of_start_date"
|
||||
ON "usage_stats" ("start_station_id" ASC, date("start_date", "unixepoch"))""")
|
||||
conn.commit()
|
||||
LOG.info("Created index: idx_start_station_id_date_of_start_date")
|
||||
conn.close()
|
||||
LOG.info("Indexes created")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user