neo4jrb / activegraph

An active model wrapper for the Neo4j Graph Database for Ruby.
http://neo4jrb.io
MIT License
1.4k stars 276 forks source link

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

Open kapone89 opened 4 years ago

kapone89 commented 4 years ago

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

Muhammad-Abdullah-11 commented 1 year ago

@kapone89 is there any progress on this issue?

kapone89 commented 1 year ago

@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?