Best Practices
Best practices and tips for getting the most out of Spice

Use recent tables

If you only need recent/near-real-time data, then use the recent tables. For example:
1
eth.recent_blocks
2
eth.recent_transactions
3
eth.recent_logs
4
eth.recent_token_transfers
5
eth.recent_token_mints
Copied!
These tables include the last 30 mins of data and are very fast to query.

Improve performance with ORDER BY, LIMIT, and OFFSET

You can significantly improve the performance of your SQL query by using limits and offsets on indexed columns. For example to fetch blocks in 1M block chunks:
1
SELECT *
2
FROM eth.blocks
3
WHERE number > 12000000
4
ORDER BY number
5
LIMIT 1000000
6
OFFSET 0
Copied!
1
SELECT *
2
FROM eth.blocks
3
WHERE number > 12000000
4
ORDER BY number
5
LIMIT 1000000
6
OFFSET 1000000
Copied!
Examples of indexed columns:

Use the Apache Arrow API and SDKs

The Apache Arrow API uses Apache Arrow Flight to deliver results over a high-performance connection. There is no limit to the number of results you can pull through the Arrow API while the HTTP API is limited to results of 500 rows.
SDKs like the Python SDK always use the Arrow API, so they are a convenient way to access Spice data.

Combine SQL with Python or other languages

Because the Arrow API makes it convenient to fetch data into pandas and NumPy formats, it's easy to use popular data science libraries and tools. Instead of doing everything in SQL, leverage both SQL and your client programming language to get the job done.