From e30563ec55b52ceeb6df48d89286a879000b0305 Mon Sep 17 00:00:00 2001 From: Matthew Eric Bassett Date: Thu, 13 Aug 2020 00:45:11 +0100 Subject: [PATCH 1/2] add - index on tx_out.payment_cred handy if you want to query utxos by payment credential. --- schema/migration-3-0004-20200810.sql | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 schema/migration-3-0004-20200810.sql diff --git a/schema/migration-3-0004-20200810.sql b/schema/migration-3-0004-20200810.sql new file mode 100644 index 000000000..641771096 --- /dev/null +++ b/schema/migration-3-0004-20200810.sql @@ -0,0 +1,25 @@ +CREATE FUNCTION migrate() RETURNS void AS $$ +DECLARE + next_version int ; +BEGIN + SELECT stage_three + 1 INTO next_version FROM schema_version ; + IF next_version <= 4 THEN + -- ------------------------------------------------------------------------- + -- More hand crafted indices for performance + + -- helpful in case anyone is looking for a utxo by a payment credential. + + CREATE INDEX idx_tx_out + ON tx_out(payment_cred); + + -- ------------------------------------------------------------------------- + + UPDATE schema_version SET stage_three = 4 ; + RAISE NOTICE 'DB has been migrated to stage_three version %', next_version ; + END IF ; +END ; +$$ LANGUAGE plpgsql ; + +SELECT migrate() ; + +DROP FUNCTION migrate() ; From 1b92a6ddf0da877a5366e77c6343cf3f108457f0 Mon Sep 17 00:00:00 2001 From: Matthew Eric Bassett Date: Thu, 13 Aug 2020 11:16:57 +0100 Subject: [PATCH 2/2] add - index on pool_update.hash_id. --- schema/migration-3-0004-20200810.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/schema/migration-3-0004-20200810.sql b/schema/migration-3-0004-20200810.sql index 641771096..9cd946cfb 100644 --- a/schema/migration-3-0004-20200810.sql +++ b/schema/migration-3-0004-20200810.sql @@ -9,9 +9,12 @@ BEGIN -- helpful in case anyone is looking for a utxo by a payment credential. - CREATE INDEX idx_tx_out + CREATE INDEX idx_tx_out_payment_cred ON tx_out(payment_cred); + CREATE INDEX idx_pool_update_hash_id + ON pool_update(hash_id); + -- ------------------------------------------------------------------------- UPDATE schema_version SET stage_three = 4 ;