From 247aa13a58578a74683d33d500404f6bb74a4baa Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Mon, 26 Feb 2018 12:57:30 +0100 Subject: [PATCH] db: Add index covering the output heights Avoids performing a table scan, now deletes on blocks are a lot faster. Signed-off-by: Christian Decker --- wallet/db.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wallet/db.c b/wallet/db.c index 0a40b0906..f113421e5 100644 --- a/wallet/db.c +++ b/wallet/db.c @@ -215,6 +215,8 @@ char *dbmigrations[] = { * die. */ "ALTER TABLE outputs ADD COLUMN confirmation_height INTEGER REFERENCES blocks(height) ON DELETE SET NULL;", "ALTER TABLE outputs ADD COLUMN spend_height INTEGER REFERENCES blocks(height) ON DELETE SET NULL;", + /* Create a covering index that covers both fields */ + "CREATE INDEX output_height_idx ON outputs (confirmation_height, spend_height);", NULL, };