Design a reliable SQL query for decoded Solana history

Use the documented table, partition, units and identity before aggregating DEX data.

A decoded dataset has an explicit schema

A SQL Indexer turns supported on-chain events into queryable tables. It is useful for analysis, but it does not imply every program, every event type or every date is present. Start with the exact schema and a small known transaction before calculating a chart or a backtest.

Use a bounded first query

SELECT slot, tx_idx, signature, block_time
FROM DOCUMENTED_TABLE
PREWHERE block_date_utc = toDate('2026-10-01')
ORDER BY slot, tx_idx
LIMIT 100

DOCUMENTED_TABLE is a placeholder. The date column and partition key must match the selected table. Supanode's schema notes describe exceptions, so do not copy block_date_utc into every table query mechanically.

Normalize with care

  1. Confirm the table actually covers the required DEX and event type.
  2. Keep raw amounts as integers and apply the token's decimals only in the appropriate calculation.
  3. Inspect whether string columns use FixedString padding before comparisons or joins.
  4. Use the documented transaction and instruction identity to avoid multiplying rows when joining several event tables.

Validate the result

Reconcile a sample against transaction evidence and check date boundaries, failed-event handling and per-column availability dates. Older rows may contain type defaults for a column introduced later. Zero can therefore mean missing historical coverage rather than a genuine zero amount. The product Docs provide the full table reference and provisioned connection details.

Sources

Continue reading