Skip to content

Commit 3fa5ecf

Browse files
authored
Merge pull request #252 from input-output-hk/erikd/indices
db: Add indices on tx_out and pool_update
2 parents e7a94d2 + cd6aa2c commit 3fa5ecf

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
CREATE FUNCTION migrate() RETURNS void AS $$
2+
DECLARE
3+
next_version int ;
4+
BEGIN
5+
SELECT stage_three + 1 INTO next_version FROM schema_version ;
6+
IF next_version <= 4 THEN
7+
-- -------------------------------------------------------------------------
8+
-- More hand crafted indices for performance
9+
10+
-- helpful in case anyone is looking for a utxo by a payment credential.
11+
12+
CREATE INDEX idx_tx_out_payment_cred
13+
ON tx_out(payment_cred);
14+
15+
CREATE INDEX idx_pool_update_hash_id
16+
ON pool_update(hash_id);
17+
18+
-- -------------------------------------------------------------------------
19+
20+
UPDATE schema_version SET stage_three = 4 ;
21+
RAISE NOTICE 'DB has been migrated to stage_three version %', next_version ;
22+
END IF ;
23+
END ;
24+
$$ LANGUAGE plpgsql ;
25+
26+
SELECT migrate() ;
27+
28+
DROP FUNCTION migrate() ;

0 commit comments

Comments
 (0)