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

The problem and solution of the first query taking a long time. 第一次查询的性能问题及解决方法 #264

Open
CorvusYe opened this issue Nov 22, 2023 · 0 comments

Comments

@CorvusYe
Copy link
Collaborator

第一种情况,查询语句组装耗时

在ngbatis对模板引擎的使用中,有一个比较重的资源使用了懒加载的方式。
日志输出对应的是:nGql make up costs 370ms,如果想把这部分时间挪到服务启动时,
可以在项目中使用以下方式,提前完成资源加载:

@Bean
public TextResolver textResolver(TextResolver resolver) {
  resolver.resolve("", Collections.emptyMap());
  return resolver;
}

第二种情况,执行查询的耗时

另外还有可能耗时的环节发生在数据库的查询上,日志输出对应的是:query costs 1091ms
如果最小连接数为 0,那么也会在第一次查询时创建连接,也会比单纯的查询本身额外消耗一些时间:
可以让最小连接数大于0,从而在服务启动时,完成连接创建,减少初次查询耗时。

nebula:
  pool-config:
    min-conns-size: 1
@CorvusYe CorvusYe added the Q&A label Nov 22, 2023
@wey-gu wey-gu added the FAQ label Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants