Lux Docs

Database

PostgreSQL schema and optimization

Core Tables

TableDescription
blocksBlock headers with consensus data
transactionsAll transaction types (0-3)
logsEvent logs from smart contracts
internal_transactionsTraces from internal calls
addressesAll seen addresses
tokensERC20/721/1155 token metadata
token_transfersToken transfer events
token_balancesHistorical token balances
smart_contractsVerified contract source code
address_coin_balancesNative coin balance history
withdrawalsEIP-4895 withdrawals

Setup

# Create database
createdb explorer

# Run migrations
mix ecto.create
mix ecto.migrate

Connection

export DATABASE_URL="postgresql://user:pass@localhost:5432/explorer?sslmode=disable"

Performance

  • Index on block_number, hash, from/to address, inserted_at
  • Partitioning by block number range for large chains
  • Connection pool: POOL_SIZE=10 (default), reduce for small chains
  • WAL mode for concurrent reads

On this page