Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add query cache #1520

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

feat: add query cache #1520

wants to merge 7 commits into from

Conversation

Cai-Yao
Copy link

@Cai-Yao Cai-Yao commented Aug 21, 2023

Task Description

Solution Description

Add query cache to cache SQL and corresponding result sets, which can get better performance in a large number of repeated query scenarios,

Passed Regressions

Upgrade Compatibility

Other Information

Release Note

@CLAassistant
Copy link

CLAassistant commented Aug 21, 2023

CLA assistant check
All committers have signed the CLA.

@@ -1390,6 +1413,13 @@ class ObSQLSessionInfo: public common::ObVersionProvider, public ObBasicSessionI
bool is_send_control_info_ = false; // whether send control info to client
bool auto_flush_trace_ = false;
bool coninfo_set_by_sess_ = false;
// use for query cache
bool use_query_cache_ = false;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这些信息可以创建一个QueryCacheCtx结构, 然后放入放到ExecContext中, 不要放在session中

int64_t row_cnt_;
common::ObArenaAllocator inner_alloc_;
common::ObSafeArenaAllocator alloc_;
DRWLock lock_;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没用, 可以删除

@@ -1338,6 +1338,13 @@ int ObSelectResolver::resolve_query_options(const ParseNode *node)
LOG_USER_ERROR(OB_ERR_CANT_USE_OPTION_HERE, "SQL_CALC_FOUND_ROWS");
}
}
LOG_INFO("ObSelectResolver resolve_query_options");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

无效日志去掉

private:
ObQueryCache() : instance_(nullptr), row_mem_size_(0), row_cnt_(0), alloc_(inner_alloc_) {}

private:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

构造函数初始化这些成员信息;

TO_STRING_KV(KP(query_cache_value_), K(handle_));
};

class ObQueryCache : public common::ObKVCache<ObQueryCacheKey, ObQueryCacheValue>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以使用MTL, 为每个租户构建一个QueryCache实例

int ObQueryCache::flush()
{
int ret = OB_SUCCESS;
destroy();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个flush 实现太粗爆, 直接将query cache对象destroy然后init一个新的, 存在与实际请求并发问题, 可以看下kv cache使用下, flush相关实现;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants