Overview
Follow these best practices to build secure, production-ready applications with the SQL API.Prioritize indexed fields for filtering
To maximize query speed, always filter your data using indexed fields. Filtering on non-indexed fields forces full table scans, which are resource-intensive. Key indexed fields for filtering (use these in your WHERE clauses):event_signature(use this instead ofevent_name)addressblock_timestamp
Select only necessary fields
Avoid usingSELECT *. Selecting unnecessary fields consumes more RAM and accesses more disk space, which increases the likelihood of your query reaching resource limits.
Leverage caching with maxAgeMs
Developers should take advantage of SQL API’s cache controls when executing high frequency queries. Ensure you’re using the maximum maxAgeMs that your queries can reasonably tolerate. This allows the API to return a cached response, which limits direct database calls.