Visualization queries provide query configuration options, including cache and sampling features. When cache is enabled, charts queried with the same conditions before data updates will use cached data, reducing query time. If cache is disabled, each page refresh or chart query will trigger a real-time query. Additionally, the sampling feature can be enabled in query configuration to further improve query speed.
Cache is enabled by default for visualization queries. When cache is enabled, the cache refreshes upon dataset synchronization to ensure query data is up to date.
To disable cache, clear the selection and apply the change. After disabling cache, each query and refresh will perform a real-time query, which may increase data query time.
For real-time datasets (Kafka, ClickHouse), you can also set the cache duration, which determines how often the cache is refreshed.
After setting the cache duration for real-time datasets, data is refreshed at each interval, ensuring the time difference between query data and actual production data remains within the cache duration, while also improving query performance.
Sampling can be enabled by selecting "Enable sampling," which increases query speed.
Once sampling is enabled, sampling fields are displayed, and you can configure the sampling type as needed.
(1) Random sampling
Applicable scenario: For large datasets with slow queries, use sampling to quickly view results.
Applicable data volume: Only available for large datasets (more than 100,000 rows).
Feature description: Sampling is performed by block (each block contains 8,192 rows), so for small datasets, the sampled row count may vary greatly and is therefore not suitable.
(2) Default sampling
Applicable scenario: Sample 200 rows from 100,000 rows to view detailed data.
Applicable data volume: Suitable for small datasets (less than 100,000 rows).
Feature description: Sampling is performed by row, but updated partitions are more likely to be sampled. Therefore, it is not suitable for large datasets or for metric calculations. In this sampling mode, if the data is not updated, the result of each sampling will be the same. Therefore, it is suitable for scenarios where the same detailed data needs to be sampled multiple times.
During visual queries, sampling is performed based on the sampling field. The smaller the percentage, the less data is processed, and the faster the visual query speed.
*Supported since version 2.68 for private deployment
In query configuration, ClickHouse-based charts can improve query speed by enabling cluster query parameters.