Replies: 2 comments 1 reply
-
Sequel uses |
Beta Was this translation helpful? Give feedback.
-
Thanks Jeremy, makes perfect sense and clarifies my understanding. As a follow up, given the structure below:
How could you query for "posts that have a comment"? I've come up with |
Beta Was this translation helpful? Give feedback.
-
I'm coming from using ActiveRecord for which only supports filtering on associations if you JOIN the associated table. I've used this gem https://github.com/MaxLap/activerecord_where_assoc which enables filtering on associations, and it uses the
EXISTS
operator.I found the documentation at http://sequel.jeremyevans.net/rdoc/files/doc/association_basics_rdoc.html#label-Filtering+By+Associations to offer similar functionality, but instead of using
EXISTS
, Sequel usesIN
.My understanding after reading https://www.percona.com/blog/2020/04/16/sql-optimizations-in-postgresql-in-vs-exists-vs-any-all-vs-join/ is you'll often get the same execution plan regardless. However, I thought it was worth discussing whether
IN
was chosen intentionally overEXISTS
, or are there other differences I'm not thinking of?Beta Was this translation helpful? Give feedback.
All reactions