New Discussion

Notifications

You’re not receiving notifications from this thread.

Where Any? vs Exists? Discussion

1
General

I don't think this is true. any? does the same optimization by itself. The reason you got a full association loaded on the first command is because of the rails console trying to output something which triggers the query. In regular application code cluster.domains.where(name: 'foo.com') would not trigger a query yet and wait until something like each or any? is sent. You can try this by appending ;nil to console commands: cluster.domains.where(name: 'foo.com');nil

Yeah I should have mentioned that in the video so that was a detail oversight on my part. I was planning to update this video to mention it. Thank you for commenting about it though so others can be aware of it until I get an update out!

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 89,392+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.