kylin-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ShaoFeng Shi <shaofeng...@apache.org>
Subject Re: query problem
Date Thu, 28 Sep 2017 07:46:20 GMT
Hi, Kylin only caches some queries which: 1) take longer time 2) scan many
rows in HBase 2) scan many bytes;

So if your query wasn't cached, it indicates that it doesn't match these
rules. The threshold of these conditions can be tunned in kylin.properties,
as we see in this part of codes.

2017-09-28 15:26 GMT+08:00 446463844@qq.com <446463844@qq.com>:

> Hi all :
> there is a problem in querying result though kylin
> I view the code in QueryService.java at kytlin
>
> ```
> public SQLResponse doQueryWithCache(SQLRequest sqlRequest) {
>  // some code
>
>        SQLResponse sqlResponse = null;
>             boolean queryCacheEnabled = checkCondition(kylinConfig.
> isQueryCacheEnabled(),
>                     "query cache disabled in KylinConfig") && //
>                     checkCondition(!BackdoorToggles.getDisableCache(),
> "query cache disabled in BackdoorToggles");
>
>             if (queryCacheEnabled) {
>                 sqlResponse = searchQueryInCache(sqlRequest);
>             }
>
>             try {
>                 if (null == sqlResponse) {
>                     sqlResponse = query(sqlRequest);
>
>                     long durationThreshold = kylinConfig.
> getQueryDurationCacheThreshold();
>                     long scanCountThreshold = kylinConfig.
> getQueryScanCountCacheThreshold();
>                     long scanBytesThreshold = kylinConfig.
> getQueryScanBytesCacheThreshold();
>                     sqlResponse.setDuration(System.currentTimeMillis() -
> startTime);
>                     logger.info("Stats of SQL response: isException: {},
> duration: {}, total scan count {}", //
>                             String.valueOf(sqlResponse.getIsException()),
> String.valueOf(sqlResponse.getDuration()),
>                             String.valueOf(sqlResponse.
> getTotalScanCount()));
>                     if (checkCondition(queryCacheEnabled, "query cache is
> disabled") //
>                             && checkCondition(!sqlResponse.getIsException(),
> "query has exception") //
>                             && checkCondition(
>                                     sqlResponse.getDuration() >
> durationThreshold
>                                             ||
> sqlResponse.getTotalScanCount() > scanCountThreshold
>                                             ||
> sqlResponse.getTotalScanBytes() > scanBytesThreshold, //
>                                     "query is too lightweight with
> duration: {} (threshold {}), scan count: {} (threshold {}), scan bytes: {}
> (threshold {})",
>                                     sqlResponse.getDuration(),
> durationThreshold, sqlResponse.getTotalScanCount(),
>                                     scanCountThreshold,
> sqlResponse.getTotalScanBytes(), scanBytesThreshold)
>                             && checkCondition(sqlResponse.getResults().size()
> < kylinConfig.getLargeQueryThreshold(),
>                                     "query response is too large: {}
> ({})", sqlResponse.getResults().size(),
>                                     kylinConfig.getLargeQueryThreshold()))
> {
>                         cacheManager.getCache(SUCCESS_QUERY_CACHE)
>                                 .put(new Element(sqlRequest.getCacheKey(),
> sqlResponse));
>                     }
> ```
> I find that set the prop 'kylin.query.cache-enabled=true' .then all the
> query though kylin will be cached
> but I send same query twice last day and found that query do htable
> scanning every time.
> this is conflict with the code.
> why?
>  best wishes!
>
>
>
> 446463844@qq.com
>



-- 
Best regards,

Shaofeng Shi 史少锋

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message