SQL has become the standard way to query Solana blockchain data. Whether you are tracking whale wallets, measuring DEX volume, or analyzing NFT sales trends, writing SQL against indexed Solana data gives you precision that no dashboard can match.
The problem is choosing the right platform. Flipside Crypto, Dune Analytics, Helius, and Google BigQuery all offer SQL access to Solana data, but they differ in schema design, data freshness, pricing, and query speed. This guide walks through each platform with setup instructions and ready-to-use queries so you can start extracting insights immediately.
If you are new to on-chain data analysis, start with our introduction to Solana on-chain data before diving into SQL-specific workflows.
Why Query Solana Data with SQL
Dashboards are useful for monitoring known metrics, but SQL unlocks questions that no pre-built dashboard anticipates. You can filter by specific programs, time windows, wallet clusters, or token mints — and combine them in ways that surfaces alpha before it becomes common knowledge.
Common use cases for SQL on Solana:
- Identify the top holders of any SPL token at a specific point in time
- Calculate daily DEX volume broken down by protocol (Jupiter, Raydium, Orca)
- Track wallet profitability across hundreds of trades
- Analyze NFT sales history by collection, marketplace, or price range
- Monitor protocol-level metrics like TVL changes, fee revenue, and user retention
Every platform covered here indexes raw Solana transactions and decodes them into structured tables you can query with standard SQL syntax.
Dune Analytics
Dune Analytics is the most popular blockchain analytics platform with a massive community of analysts sharing public queries and dashboards. Its Solana support covers decoded program data, token transfers, DEX trades, and NFT events.
Setting Up Dune
- Create a free account at dune.com
- Navigate to the query editor (New Query)
- Select "Solana" from the database dropdown
- Start writing SQL using DuneSQL syntax (Trino-based)
Dune's free tier gives you 2,500 monthly executions with a 6-minute timeout per query. The Plus plan ($349/month) unlocks private queries, faster execution, and CSV exports.
Dune Schema Overview
Dune organizes Solana data into several key schemas:
solana.transactions — All Solana transactions with fee, signer, and status data
solana.account_activity — Account balance changes per transaction
tokens_solana.transfers — Decoded SPL token transfers
dex_solana.trades — Aggregated DEX trades across all major Solana DEXs
nft_solana.trades — NFT marketplace sales data
Example: Daily DEX Volume on Solana
SELECT
date_trunc('day', block_time) AS trade_date,
project AS dex,
COUNT(*) AS trade_count,
SUM(amount_usd) AS volume_usd
FROM dex_solana.trades
WHERE block_time >= NOW() - INTERVAL '30' DAY
GROUP BY 1, 2
ORDER BY 1 DESC, 4 DESC
This query returns daily DEX volume per protocol over the last 30 days. You can filter by specific DEX names like 'jupiter' or 'raydium' to narrow results.
Example: Top Token Holders
SELECT
to AS wallet,
SUM(CASE WHEN to = wallet THEN amount ELSE 0 END)
- SUM(CASE WHEN "from" = wallet THEN amount ELSE 0 END) AS net_balance
FROM tokens_solana.transfers
WHERE token_mint_address = '{{token_mint}}'
GROUP BY 1
HAVING net_balance > 0
ORDER BY 2 DESC
LIMIT 100
Replace {{token_mint}} with any SPL token mint address. Dune supports parameterized queries, so you can create a reusable dashboard widget for any token.
Flipside Crypto
Flipside takes a different approach by providing curated, pre-modeled data tables that are easier to query than raw transaction data. Their Solana coverage includes decoded program events, labelled wallet addresses, and clean swap tables.
Setting Up Flipside
- Sign up at flipsidecrypto.xyz
- Open the SQL editor from the dashboard
- Browse available Solana tables under the
solana schema
- Write queries using Snowflake SQL syntax
The free tier includes 5,000 query-seconds per month. The Pro plan ($49/month) adds more compute, private queries, and API access for programmatic data pulls.
Flipside Schema Overview
Flipside's Solana tables are well-organized:
solana.core.fact_transactions — Transaction-level data with fees, signers, and success status
solana.core.fact_transfers — All SOL and SPL token transfers
solana.core.fact_events — Decoded program events
solana.defi.fact_swaps — DEX swap data with clean token symbols and USD values
solana.nft.fact_nft_sales — NFT marketplace transactions
solana.core.dim_labels — Known wallet labels (exchanges, protocols, whales)
Example: Wallet Profitability Analysis
WITH buys AS (
SELECT
swapper AS wallet,
swap_to_mint AS token,
SUM(swap_to_amount) AS tokens_bought,
SUM(swap_from_amount * COALESCE(swap_from_decimal_price, 0)) AS cost_usd
FROM solana.defi.fact_swaps
WHERE swapper = '{{wallet_address}}'
AND block_timestamp >= CURRENT_DATE - 30
GROUP BY 1, 2
),
sells AS (
SELECT
swapper AS wallet,
swap_from_mint AS token,
SUM(swap_from_amount) AS tokens_sold,
SUM(swap_to_amount * COALESCE(swap_to_decimal_price, 0)) AS revenue_usd
FROM solana.defi.fact_swaps
WHERE swapper = '{{wallet_address}}'
AND block_timestamp >= CURRENT_DATE - 30
GROUP BY 1, 2
)
SELECT
b.token,
b.tokens_bought,
COALESCE(s.tokens_sold, 0) AS tokens_sold,
b.cost_usd,
COALESCE(s.revenue_usd, 0) AS revenue_usd,
COALESCE(s.revenue_usd, 0) - b.cost_usd AS pnl_usd
FROM buys b
LEFT JOIN sells s ON b.token = s.token
ORDER BY pnl_usd DESC
This query calculates profit and loss per token for a given wallet over the last 30 days. It pairs buy and sell activity to show which tokens were profitable.
Helius DAS and SQL Access
Helius is primarily an RPC and API provider, but its Digital Asset Standard (DAS) API and enhanced transaction endpoints let you query Solana data programmatically. While Helius does not offer a traditional SQL editor, you can pipe its structured JSON responses into your own database for SQL analysis.
Setting Up Helius for Data Queries
- Sign up at helius.dev and get your API key
- Use the DAS API for asset and ownership queries
- Use Enhanced Transaction API for decoded transaction history
- Load results into a local PostgreSQL or SQLite database for SQL analysis
The free tier provides 100,000 credits/month. For heavy data analysis, the Business plan offers higher limits and priority access.
Example: Query Top Holders via DAS API
// Fetch top holders for a token mint using Helius DAS
const response = await fetch(
`https://mainnet.helius-rpc.com/?api-key=${API_KEY}`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "getTokenAccounts",
params: {
mint: "TOKEN_MINT_ADDRESS",
limit: 100,
options: { showZeroBalance: false }
}
})
}
);
Once you load this data into a local database, you can run standard SQL queries against it. This approach is best when you need real-time data that analytics platforms might lag behind on.
Example: NFT Sales History via Enhanced Transactions
// Fetch NFT transaction history
const response = await fetch(
`https://api.helius.xyz/v0/addresses/${NFT_MINT}/transactions?api-key=${API_KEY}&type=NFT_SALE`
);
const sales = await response.json();
// Insert into local DB for SQL analysis
Helius is ideal when you need the freshest data possible or when your analysis requires combining on-chain data with off-chain sources in a custom database.
Google BigQuery (Solana Warehouse)
Google BigQuery provides access to Solana blockchain data through the public dataset bigquery-public-data.crypto_solana_mainnet_us. This is a fully managed warehouse with no indexing required and virtually unlimited compute for large-scale analysis.
Setting Up BigQuery
- Go to console.cloud.google.com and create a project
- Navigate to BigQuery in the left sidebar
- Search for
crypto_solana in the public datasets explorer
- Pin the dataset to your project for easy access
BigQuery offers 1 TB of free query processing per month. For most Solana analysis tasks, this is more than enough. Billing kicks in at $6.25 per TB scanned after the free tier.
BigQuery Schema Overview
The Solana public dataset includes:
transactions — Full transaction data including instructions and logs
blocks — Block-level metadata (slot, timestamp, leader)
accounts — Account state snapshots
token_transfers — Decoded SPL token transfer events
rewards — Validator and staking rewards
Example: NFT Sales History
SELECT
t.block_timestamp,
t.signatures[OFFSET(0)] AS tx_signature,
tt.source AS seller,
tt.destination AS buyer,
tt.value / 1e9 AS price_sol
FROM `bigquery-public-data.crypto_solana_mainnet_us.transactions` t,
UNNEST(t.token_transfers) tt
WHERE tt.mint = '{{nft_collection_mint}}'
AND t.block_timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 90 DAY)
AND t.success = TRUE
ORDER BY t.block_timestamp DESC
LIMIT 500
BigQuery shines for historical analysis across large time ranges where other platforms might time out. Scanning a full year of Solana DEX data is routine on BigQuery but can be painful on platforms with execution time limits.
Platform Comparison
| Feature | Dune Analytics | Flipside Crypto | Helius | Google BigQuery |
|---|
| SQL dialect | DuneSQL (Trino) | Snowflake SQL | N/A (API) | GoogleSQL |
| Free tier | 2,500 queries/mo | 5,000 query-sec/mo | 100K credits/mo | 1 TB queries/mo |
| Data freshness | Near real-time | Near real-time | Real-time | 1-6 hour lag |
| Query speed | Moderate | Fast | Instant (API) | Fast for large scans |
| Decoded DEX data | Yes | Yes | Via parsed tx | Limited |
| NFT sales tables | Yes | Yes | Via DAS API | Raw transfers only |
| Wallet labels | Community | Built-in | No | No |
| Visualization | Built-in charts | Built-in charts | No | Looker Studio |
| API access | Paid plans | Pro plan | All plans | All plans |
| Best for | Community dashboards, research | Clean data models, wallets | Real-time data, app backends | Large-scale historical analysis |
Choosing the right platform:
- Exploratory analysis and sharing: Start with Dune. The community queries save you hours of work, and you can fork existing dashboards.
- Clean wallet and DeFi analysis: Use Flipside. The curated data models and wallet labels make profitability queries straightforward.
- Real-time application data: Use Helius. When your app needs fresh data with millisecond latency, an API beats a query platform.
- Large historical scans: Use BigQuery. Scanning months of data without timeout limits is where BigQuery excels.
For a broader comparison of analytics tools, see our guide on the best Solana analytics dashboards.
Practical Tips for Solana SQL Queries
Optimize for cost and speed:
- Always filter by
block_time or block_timestamp first. Time-partitioned columns dramatically reduce the amount of data scanned.
- Use
LIMIT during development. A query that returns 10 million rows wastes compute even if you only look at the first 100.
- Avoid
SELECT * on transaction tables. Solana transactions contain nested instruction data that inflates scan size.
Handle Solana-specific quirks:
- Token amounts are stored as integers. Divide by
10^decimals to get human-readable values. Most platforms provide a decimal column or pre-divided amount.
- A single Solana transaction can contain dozens of inner instructions. When counting "trades" or "transfers," be specific about which instruction types you include.
- Wallet addresses on Solana are base58-encoded. Most SQL platforms store them as strings, so text matching and grouping works normally.
Combine platforms for the best results:
Use Dune or Flipside for discovery and exploration, then move to Helius or BigQuery for production pipelines that need reliability and freshness. Many analysts use Dune to prototype a query, then replicate it in BigQuery for scheduled reporting.
For deeper guidance on working with historical Solana data, check out our historical data access and analysis guide.
Frequently Asked Questions
Is it free to query Solana data with SQL?
Yes, every platform covered in this guide offers a free tier that is sufficient for learning and moderate analysis. Dune provides 2,500 free query executions per month, Flipside offers 5,000 query-seconds, Google BigQuery includes 1 TB of free query processing, and Helius gives 100,000 API credits. You can accomplish serious research without paying anything. Paid tiers become necessary when you need private queries, higher execution limits, or programmatic API access for production applications.
Which platform has the freshest Solana data?
Helius provides the freshest data because it queries the Solana blockchain directly via RPC and API calls, giving you real-time results with no indexing delay. Dune Analytics and Flipside Crypto both operate at near real-time freshness, typically lagging by a few minutes as they index and decode new blocks. Google BigQuery has the longest delay, often ranging from one to six hours depending on the dataset refresh schedule. If your analysis requires data from the most recent blocks, Helius is the best choice. For anything older than an hour, all four platforms provide equivalent data.
Can I use these SQL platforms to build automated trading strategies?
You can use them for the analytical component of a trading strategy, but none of these platforms are designed for real-time trade execution. Dune and Flipside are best suited for backtesting strategies, identifying patterns, and generating watchlists. Helius can feed real-time data into a trading bot via its API and webhooks. BigQuery works well for batch analysis that runs on a schedule. The typical workflow is to use SQL analysis to identify opportunities, then execute trades through a separate system connected to Jupiter or Raydium. See our on-chain data analysis guide for more on turning data into actionable insights.
Do I need to know advanced SQL to get useful results?
Basic SQL knowledge is enough to extract significant value from Solana data. If you can write SELECT, WHERE, GROUP BY, and JOIN statements, you can answer most common questions about token holders, trading volumes, and wallet activity. Dune and Flipside both have large libraries of community queries you can fork and modify without writing anything from scratch. More advanced techniques like window functions, CTEs, and subqueries become useful for complex analyses like wallet profitability tracking or time-series comparisons, but you can learn these incrementally as your questions get more sophisticated.