[Supanode](https://supanode.xyz/)[Learn](https://supanode.xyz/learn)Design a reliable SQL query for decoded Solana history

# Design a reliable SQL query for decoded Solana history

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

**On this page**[A decoded dataset has an explicit schema](https://supanode.xyz/learn/query-decoded-solana-history#a-decoded-dataset-has-an-explicit-schema)[Use a bounded first query](https://supanode.xyz/learn/query-decoded-solana-history#use-a-bounded-first-query)[Normalize with care](https://supanode.xyz/learn/query-decoded-solana-history#normalize-with-care)[Validate the result](https://supanode.xyz/learn/query-decoded-solana-history#validate-the-result)[Sources](https://supanode.xyz/learn/query-decoded-solana-history#sources)

## 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

-   [Supanode schema conventions](https://supanode.xyz/docs/solana/indexer/database-schema)
-   [Supanode table reference](https://supanode.xyz/docs/solana/indexer/tables)
-   [ClickHouse PREWHERE](https://clickhouse.com/docs/sql-reference/statements/select/prewhere)

## Continue reading

[Solana streaming guide](https://supanode.xyz/blog/solana-data-streaming-guide)[Solana product Docs](https://supanode.xyz/docs/solana/quickstart)[Learn library](https://supanode.xyz/learn)

---
Source: https://supanode.xyz/learn/query-decoded-solana-history
