Skip to content

Commit e8050ee

Browse files
committed
docs: align partitioning strategy with LIST by chain_id
Update database schema documentation to use LIST partitioning by chain_id instead of TimescaleDB time-based partitioning, aligning with the primary nonce-based query pattern. Changes: - Replace partition examples with LIST by chain_id approach - Add nonce-based indexes as primary access pattern - Add time-based indexes as secondary (for export endpoint) - Emphasize partition-specific indexes for high-volume chains
1 parent 1c8e20b commit e8050ee

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

docs/phase-2-3/database-schema.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -765,19 +765,40 @@ CREATE INDEX idx_multisig_tx_safe_nonce ON multisig_transactions(chain_id, safe,
765765
CREATE INDEX idx_erc20_to_from ON erc20_transfers(chain_id, to_address, from_address);
766766
```
767767

768-
### 2. Partition Large Tables
768+
### 2. Partition Large Tables (LIST by chain_id)
769769

770770
```sql
771-
-- Partition by chain_id for multi-chain support
772-
CREATE TABLE multisig_transactions_partitioned (
773-
-- same columns
771+
-- LIST partition by chain_id (matches nonce-based query pattern)
772+
CREATE TABLE multisig_transactions (
773+
chain_id INTEGER NOT NULL,
774+
safe_address BYTEA NOT NULL,
775+
safe_tx_hash BYTEA NOT NULL,
776+
nonce INTEGER NOT NULL,
777+
created TIMESTAMP NOT NULL,
778+
-- ... other fields
774779
) PARTITION BY LIST (chain_id);
775780

776-
CREATE TABLE multisig_transactions_chain_1
777-
PARTITION OF multisig_transactions_partitioned FOR VALUES IN (1);
781+
-- High-volume chains get dedicated partitions
782+
CREATE TABLE multisig_transactions_worldchain
783+
PARTITION OF multisig_transactions FOR VALUES IN (480);
778784

779-
CREATE TABLE multisig_transactions_chain_137
780-
PARTITION OF multisig_transactions_partitioned FOR VALUES IN (137);
785+
CREATE TABLE multisig_transactions_ethereum
786+
PARTITION OF multisig_transactions FOR VALUES IN (1);
787+
788+
CREATE TABLE multisig_transactions_polygon
789+
PARTITION OF multisig_transactions FOR VALUES IN (137);
790+
791+
-- Low-volume chains grouped
792+
CREATE TABLE multisig_transactions_others
793+
PARTITION OF multisig_transactions DEFAULT;
794+
795+
-- PRIMARY INDEX: nonce-based queries (most common)
796+
CREATE INDEX idx_tx_chain_safe_nonce
797+
ON multisig_transactions (chain_id, safe_address, nonce DESC);
798+
799+
-- SECONDARY INDEX: time-based queries (export endpoint, rare)
800+
CREATE INDEX idx_tx_chain_safe_created
801+
ON multisig_transactions (chain_id, safe_address, created DESC);
781802
```
782803

783804
### 3. Use CTEs for Complex Queries

0 commit comments

Comments
 (0)