Neo4j查询执行时间:多次执行同一查询时,似乎只有第一个是正确的 [英] Neo4j query execution time: when executing the same query multiple times, only the first one seems to be correct

查看:82
本文介绍了Neo4j查询执行时间:多次执行同一查询时,似乎只有第一个是正确的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用LDBC数据集来测试Neo4j 4.0.1中的执行时间,SF = 1,我使用Java连接Neo4j ResultSummary.resultAvailableAfter()来获取执行时间,这是获取结果的时间并开始流式传输.但是对于同一查询,当我第一次运行时,执行时间似乎很合理,就像几百毫秒一样,但是当我继续运行同一查询时,执行时间几乎变为0.我想这是查询缓存的作用,但是有没有适当的方法来测试查询执行时间并获得合理的结果呢?

I'm using LDBC dataset to test execution time in Neo4j 4.0.1, SF = 1, and I use java to connect Neo4j, ResultSummary.resultAvailableAfter() to get the execution time, which is the time to get the result and start streaming. But for the same query, when I run for the first time, the execution time seems reasonable, like hundreds of ms, but when I continue running this same query, the execution time becomes almost 0. I guess it's effect of query cache, but is there any proper approach to test query execution time and get a reasonable result?

现在,我只能重新启动db才能获得似乎正确的结果.我猜这是因为Neo4j直接缓存查询结果,并且如果多次执行相同的查询就只获取它.有什么办法可以避免这种情况?即让neo4j进行常规缓存(例如节点和关系),而不是直接缓存查询结果.谢谢!

Now I can only restart db to get the result that seems to be correct. I guess it's because Neo4j directly caches the query result and just fetches it if the same query is executed multiple times. Is there any way to avoid this? i.e. let neo4j do normal caching (like nodes and relationships), not directly cache query result. Thanks!

推荐答案

页面缓存最有可能负责您所看到的结果(好吧,在构建Neo4j集群时,我与neo4j工程师进行了一些讨论.他们关于优化集群性能的建议似乎表明了这一点.您应该将页面缓存大小设置为0或非常接近0(例如1Meg或较低).您可以在 https://neo4j.com上了解有关内存设置的信息./docs/operations-manual/current/performance/memory-configuration/

The page cache most likely is responsible for the results you are seeing (Well, i had some discussions with neo4j engineers when i was working on building a neo4j cluster. Their suggestions to optimize our cluster performance seemed to indicate this). You should set the page cache size to 0 or very close to 0 (say 1Meg or something low). You can read about the memory settings here https://neo4j.com/docs/operations-manual/current/performance/memory-configuration/

您需要更改的特定设置是

The specific setting you need to change is

dbms.memory.pagecache.size=1M 

或将其设置为0.将其明确设置为一个值.不要对此设置发表评论.neo4j可以为页面缓存分配默认的内存大小.设置更改后,重新启动服务器/群集,然后查看所提供的性能数字.您还应该通过运行

or set it 0. Explicitly set this to a value. Dont leave this setting commented. neo4j may assign default memory size to page cache. Restart your server/cluster after the settings change and see what performance numbers you come up with. You should also check how your cache looks by running

:sysinfo

命令.

并且没有直接的设置可以告诉neo4j缓存什么.那是正确的,由服务器本身决定.

And there is no direct setting to tell neo4j what to cache. That is, rightly, decided by the server itself.

对不起,我没有足够的声誉积分,无法对您的问题发表评论!

Sorry, i dont have enough reputation points to leave a comment to your question!

这篇关于Neo4j查询执行时间:多次执行同一查询时,似乎只有第一个是正确的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆