activegraph icon indicating copy to clipboard operation
activegraph copied to clipboard

Methods like .empty? or .size doesn't work well with eager loading

Open kapone89 opened this issue 4 years ago • 2 comments

When we preload an association, methods like .empty? or .size still produce a query

It cause an N+1 queries issues when we use this gem together with fast_jsonapi gem. See this: https://github.com/Netflix/fast_jsonapi/blob/master/lib/fast_jsonapi/serialization_core.rb#L130

Code example (inline, gist, or repo)

user = User.all.with_associations(:posts).first
user.posts # <- no query
user.posts.size # <- query
user.posts.empty? # <- query

Runtime information:

Neo4j database version: 3.5.12 neo4j gem version: 9.6.2 neo4j-core gem version: 9.0.0

kapone89 avatar May 14 '20 08:05 kapone89

@kapone89 is there any progress on this issue?

Muhammad-Abdullah-11 avatar May 10 '23 00:05 Muhammad-Abdullah-11

@Muhammad-Abdullah-11 I don't know. I'm not in the project using neo4j anymore. It was long time ago 😄 @polecpiotr maybe you can check if it's still valid?

kapone89 avatar May 22 '23 08:05 kapone89