[enhancement](stats) Make stats cache item size configurable (#19205)
This commit is contained in:
@ -50,11 +50,6 @@ public class StatisticConstants {
|
||||
*/
|
||||
public static final int STATISTIC_CLEAN_INTERVAL_IN_HOURS = 24 * 2;
|
||||
|
||||
/**
|
||||
* The max cached item in `StatisticsCache`.
|
||||
*/
|
||||
public static final long STATISTICS_RECORDS_CACHE_SIZE = 100000;
|
||||
|
||||
/**
|
||||
* If analysis job execution time exceeds this time, it would be cancelled.
|
||||
*/
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
|
||||
package org.apache.doris.statistics;
|
||||
|
||||
import org.apache.doris.common.Config;
|
||||
import org.apache.doris.common.ThreadPoolManager;
|
||||
import org.apache.doris.qe.ConnectContext;
|
||||
import org.apache.doris.statistics.util.InternalQueryResult.ResultRow;
|
||||
@ -53,7 +54,7 @@ public class StatisticsCache {
|
||||
|
||||
private final AsyncLoadingCache<StatisticsCacheKey, Optional<ColumnStatistic>> columnStatisticsCache =
|
||||
Caffeine.newBuilder()
|
||||
.maximumSize(StatisticConstants.STATISTICS_RECORDS_CACHE_SIZE)
|
||||
.maximumSize(Config.stats_cache_size)
|
||||
.expireAfterAccess(Duration.ofHours(StatisticConstants.STATISTICS_CACHE_VALID_DURATION_IN_HOURS))
|
||||
.refreshAfterWrite(Duration.ofHours(StatisticConstants.STATISTICS_CACHE_REFRESH_INTERVAL))
|
||||
.executor(threadPool)
|
||||
@ -61,7 +62,7 @@ public class StatisticsCache {
|
||||
|
||||
private final AsyncLoadingCache<StatisticsCacheKey, Optional<Histogram>> histogramCache =
|
||||
Caffeine.newBuilder()
|
||||
.maximumSize(StatisticConstants.STATISTICS_RECORDS_CACHE_SIZE)
|
||||
.maximumSize(Config.stats_cache_size)
|
||||
.expireAfterAccess(Duration.ofHours(StatisticConstants.STATISTICS_CACHE_VALID_DURATION_IN_HOURS))
|
||||
.refreshAfterWrite(Duration.ofHours(StatisticConstants.STATISTICS_CACHE_REFRESH_INTERVAL))
|
||||
.executor(threadPool)
|
||||
|
||||
@ -23,6 +23,7 @@ import org.apache.doris.catalog.Column;
|
||||
import org.apache.doris.catalog.Env;
|
||||
import org.apache.doris.catalog.Partition;
|
||||
import org.apache.doris.common.AnalysisException;
|
||||
import org.apache.doris.common.Config;
|
||||
import org.apache.doris.common.DdlException;
|
||||
import org.apache.doris.common.FeConstants;
|
||||
import org.apache.doris.statistics.util.DBObjects;
|
||||
@ -104,7 +105,7 @@ public class StatisticsRepository {
|
||||
+ FeConstants.INTERNAL_DB_NAME + "." + StatisticConstants.STATISTIC_TBL_NAME
|
||||
+ " WHERE part_id is NULL "
|
||||
+ " ORDER BY update_time DESC LIMIT "
|
||||
+ StatisticConstants.STATISTICS_RECORDS_CACHE_SIZE;
|
||||
+ Config.stats_cache_size;
|
||||
|
||||
private static final String FETCH_STATS_FULL_NAME =
|
||||
"SELECT id, catalog_id, db_id, tbl_id, idx_id, col_id, part_id FROM "
|
||||
|
||||
Reference in New Issue
Block a user