-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Look in to changing how array.includes() criteria method works #968
Comments
I think the best case here is that avram just constructs the database with the GIN index and then queries it accordingly. For the backwards incompatibility, for when an avram app/database which has been constructed before that change, or for a database that exists outside of Avrams control, perhaps an opt-in model-level settings interface would be helpful? Ecto accomplishes this sort of thing with compile-time attributes on the models, kind of like annotations. For example you can configure your application to prefer UUID style ID columns, but then override it on a per-model basis if you want. |
I like the idea of adding some annotations to sort of configure your setup. How would that work here? Maybe something in your AppDatabase? 🤔 @[Avram::IncludesCriteria(use_any: false)]
class AppDatabase < Avram::Database
end |
Just merged in the
The second one isn't too bad.. If you're upgrading you're most likely reading CHANGELOG and stuff anyway, and that could easily be mentioned as a "don't forget to....". The first concern though we'd either have to come up with a new name for it, or maybe an option to the method? |
avram/src/avram/criteria_extensions/includes_criteria.cr
Lines 3 to 7 in f84e111
Using this method in a query is handy. If one of your columns is an
Array(?)
column, you can get records where that array contains some valueHowever, I just learned that if you put a
GIN
index ontags
, postgres won't actually use the index in this way...Using a GIN index
Query as-is now
But there seems to be an alternate way of doing this query which is a ton faster
This is a pretty big improvement. Though, I should note that without an index, the first way queries twice as fast as the second way...
The text was updated successfully, but these errors were encountered: