You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: database/src/postgres/migrations/shard_db/20250218132509_create_state_changes_compact.up.sql
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,8 @@ DECLARE
14
14
BEGIN
15
15
FOR i IN0..99 LOOP
16
16
EXECUTE format('CREATE TABLE IF NOT EXISTS state_changes_data_compact_%s PARTITION OF state_changes_data_compact FOR VALUES WITH (MODULUS 100, REMAINDER %s)', i, i);
17
+
-- Indexes for state_changes_data_compact partitions
18
+
EXECUTE format('CREATE INDEX IF NOT EXISTS idx_data_%s_keys ON state_changes_data_compact_%s (account_id, data_key) WHERE block_height_to IS NULL;', i, i);
17
19
END LOOP;
18
20
END $$;
19
21
@@ -34,6 +36,8 @@ DECLARE
34
36
BEGIN
35
37
FOR i IN0..99 LOOP
36
38
EXECUTE format('CREATE TABLE IF NOT EXISTS state_changes_access_key_compact_%s PARTITION OF state_changes_access_key_compact FOR VALUES WITH (MODULUS 100, REMAINDER %s)', i, i);
39
+
-- Indexes for state_changes_access_key_compact partitions
40
+
EXECUTE format('CREATE INDEX IF NOT EXISTS idx_access_key_%s_keys ON state_changes_access_key_compact_%s (account_id, data_key) WHERE block_height_to IS NULL;', i, i);
37
41
END LOOP;
38
42
END $$;
39
43
@@ -53,6 +57,8 @@ DECLARE
53
57
BEGIN
54
58
FOR i IN0..99 LOOP
55
59
EXECUTE format('CREATE TABLE IF NOT EXISTS state_changes_contract_compact_%s PARTITION OF state_changes_contract_compact FOR VALUES WITH (MODULUS 100, REMAINDER %s)', i, i);
60
+
-- Indexes for state_changes_contract_compact partitions
61
+
EXECUTE format('CREATE INDEX IF NOT EXISTS idx_contract_%s_acc ON state_changes_contract_compact_%s (account_id) WHERE block_height_to IS NULL;', i, i);
56
62
END LOOP;
57
63
END $$;
58
64
@@ -71,5 +77,7 @@ DECLARE
71
77
BEGIN
72
78
FOR i IN0..99 LOOP
73
79
EXECUTE format('CREATE TABLE IF NOT EXISTS state_changes_account_compact_%s PARTITION OF state_changes_account_compact FOR VALUES WITH (MODULUS 100, REMAINDER %s)', i, i);
80
+
-- Indexes for state_changes_account_compact partitions
81
+
EXECUTE format('CREATE INDEX IF NOT EXISTS idx_account_%s_acc ON state_changes_account_compact_%s (account_id) WHERE block_height_to IS NULL;', i, i);
0 commit comments