Query Referencing
Easily reference results from exiting queries!
Last updated
Easily reference results from exiting queries!
Last updated
Query Referencing allows you to streamline your analysis workflow by reusing the results of previously executed queries as data sources for new queries. This feature enhances query organization, promotes reusability of complex result sets, and significantly boosts query performance.
This section will cover:
Identify the Query:
Navigate to the desired query and click "Copy Reference" button to obtain the query ID.
To reference your own query, find the query you want to reference under "My Work". Click the 3-dot menu, and select "Add to Query".
Reference the Query:
In your new query, use the following syntax to reference the query:
Join with other tables:
You can join the referenced query with other tables in your dataset:
A significant advantages of Query Referencing is its ability to dramatically improve the performance of parameterized queries.
Pre-calculate the 100,000 most relevant addresses:
Reference the pre-calculated result:
By pre-calculating the relevant addresses and referencing the result, you can significantly improve query performance, especially when dealing with large datasets and frequent parameter changes.
Do Your Own Research (DYOR): Always verify the logic and accuracy of the referenced query.
Since all public queries can be referenced, make sure you trace query dependencies! Hover over any $query('query_id')
and click on the query title in the popover to view all information about the underlying query.
Consider Query Refresh Rates: Ensure that the referenced query is refreshed at an appropriate interval to provide up-to-date results.
To ensure up-to-date results, set a "Refresh Rate" on your base query
Any new query referencing the results will automatically use the refreshed data
Refreshes follow standard query refresh capabilities
Understand Cache Expiration: Be aware of the cache duration and expiration rules for referenced queries.
Results are cached and available for 24 hours by default
Each reference within the 24-hour window extends availability by another 24 hours
Maximum cache duration is 31 days
Base queries that utilize parameters will always execute with their default values when referenced. Currently, there’s no mechanism to dynamically pass parameters into the $query() function. It is best to avoid using parameters in your base queries.