Neo4j query execution time: when executing the same query multiple times, only the first one seems to be correct

∥☆過路亽.° 提交于 2021-01-28 17:52:36

问题


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?

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!


回答1:


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 

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

command in the browser before and after running your queries.

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!



来源:https://stackoverflow.com/questions/60680417/neo4j-query-execution-time-when-executing-the-same-query-multiple-times-only-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!