-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathindexes.sql
More file actions
57 lines (51 loc) · 2.64 KB
/
Copy pathindexes.sql
File metadata and controls
57 lines (51 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
-- ============================================================================
-- Cardano GraphQL Performance Indexes
-- ============================================================================
--
-- This file contains recommended indexes for improving query performance.
-- All indexes use CONCURRENTLY to avoid blocking db-sync writes.
--
-- IMPORTANT: Index creation can take several hours on mainnet (up to 6 hours).
-- Progress can be monitored via: docker compose logs -f index-service
--
-- To enable: Set COMPOSE_PROFILES=token-registry,indexes in your .env file
-- To disable: Remove 'indexes' from COMPOSE_PROFILES
-- ============================================================================
\echo '======================================================================'
\echo 'Starting Cardano GraphQL Index Creation'
\echo '======================================================================'
\echo ''
\echo '[1/3] Creating index on tx_out.address (hash on text expression)...'
DROP INDEX CONCURRENTLY IF EXISTS idx_tx_out_address;
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_tx_out_address_texthash ON tx_out USING hash ((address::text));
\echo '✓ Completed: idx_tx_out_address_texthash'
\echo ''
\echo '[2/3] Creating index on asset.fingerprint...'
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_asset_fingerprint ON "Asset"(fingerprint);
\echo '✓ Completed: idx_asset_fingerprint'
\echo ''
\echo '[3/3] Creating index on ma_tx_mint.ident (speeds up asset polling)...'
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ma_tx_mint_ident ON ma_tx_mint(ident);
\echo '✓ Completed: idx_ma_tx_mint_ident'
\echo ''
-- ============================================================================
-- Summary
-- ============================================================================
\echo ''
\echo '======================================================================'
\echo 'Index Creation Complete!'
\echo '======================================================================'
\echo ''
\echo 'All performance indexes have been created successfully.'
\echo 'Your Cardano GraphQL instance should now experience improved query performance.'
\echo ''
\echo 'To verify indexes were created, run:'
\echo ' docker compose exec postgres psql -U <user> -d <db> -c "\\di idx_*"'
\echo ''
\echo 'Indexes created:'
\echo ' idx_tx_out_address_texthash - speeds up payment address / UTXO-by-address queries'
\echo ' idx_asset_fingerprint - speeds up asset fingerprint lookups'
\echo ' idx_ma_tx_mint_ident - speeds up new asset polling'
\echo ''
\echo 'The index-service container will now exit.'
\echo '======================================================================'