From 655e79b6084d90ddeaabe495a354c5e9d53bd9c6 Mon Sep 17 00:00:00 2001 From: fly Date: Mon, 7 Sep 2020 23:45:29 +1000 Subject: [PATCH] Create index to speed up queries Signed-off-by: fly --- init-db.py | 1 + 1 file changed, 1 insertion(+) diff --git a/init-db.py b/init-db.py index 7fbfb74..6d94d18 100755 --- a/init-db.py +++ b/init-db.py @@ -83,6 +83,7 @@ cursor.execute("CREATE TABLE IF NOT EXISTS status (id INT PRIMARY KEY AUTO_INCRE cursor.execute("CREATE TABLE IF NOT EXISTS topLevel (id INT PRIMARY KEY AUTO_INCREMENT, name CHAR(7) UNIQUE NOT NULL, status_id INT NOT NULL, FOREIGN KEY (status_id) REFERENCES status(id));") cursor.execute("CREATE TABLE IF NOT EXISTS secondLevel (id INT PRIMARY KEY AUTO_INCREMENT, name CHAR(7) UNIQUE NOT NULL, status_id INT NOT NULL, parent_id INT NOT NULL, FOREIGN KEY (status_id) REFERENCES status(id), FOREIGN KEY (parent_id) REFERENCES topLevel(id));") cursor.execute("CREATE TABLE IF NOT EXISTS tile (id INT PRIMARY KEY AUTO_INCREMENT, status_id INT NOT NULL, parent_id INT NOT NULL, FOREIGN KEY (status_id) REFERENCES status(id), FOREIGN KEY (parent_id) REFERENCES secondLevel(id));") +cursor.execute("CREATE INDEX IF NOT EXISTS tile_index on tile(status_id, parent_id);") for state in states: