Optimize performance with query time sampling in Amplitude Analytics
Querying large datasets can be time-consuming, resource-heavy, and difficult to execute. Amplitude's query engine can use a technique called query time sampling to optimize performance and reduce execution time.
With query time sampling enabled, Amplitude's query engine selects a representative subset of data—specifically, events based on a randomly selected 10% sample of users—for analysis. It then up-samples the results, using advanced statistical methods like inverse sampling to extrapolate them to the entire population.
Up-sampling is useful for functions that scale with the number of users, such as totals and uniques. Amplitude doesn't use it for functions that don't scale the same way, like average, min, and max.
Enable query time sampling
To enable query time sampling in a chart:
- From a Funnel Analysis, click the lightning bolt. The lightning bolt updates to show the percentage of the dataset that the chart queries.
- To query the full dataset, click Sampled: 10% to turn off query time sampling.
Set query time sampling as the default
Project administrators can set query time sampling as the default for all new charts in a project.
- Navigate to your project's settings.
- Enable the toggle for Query Time Sampling.
Dashboard query time sampling
To enable query time sampling for a dashboard that contains more than one chart, go to the dashboard toolbar and click Sampling to toggle sampling on or off for the dashboard.
After you enable it, the dashboard shows that query time sampling is enabled. Each chart also displays a lightning bolt icon:
- A blue icon means the chart uses sampled data.
- A red icon means the chart's analysis runs on a small set of data, and the sampled data may not accurately reflect the full dataset.
When you enable sampling on a dashboard and open a chart, the chart opens with sampling turned on.
Caveats
Query time sampling can streamline your workflow, but keep a few things in mind:
- It may not always suit all types of analyses. These include queries with small datasets, queries that require a high level of granularity, or queries looking for property max, min, or count when the data is highly variable.
- The following features are unavailable with query time sampling enabled in Amplitude Analytics: create cohorts, set monitors and alerts, scale sampling during data ingestion, and account analysis.
Was this helpful?