Browse Source

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 <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
parent
commit
247aa13a58
  1. 2
      wallet/db.c

2
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,
};

Loading…
Cancel
Save