Re: Proposal to not implicitly create varchar/text-pattern opclass indexes on PostgreSQL

2020-04-14 Thread Hannes Ljungberg
The `*_pattern_ops` operators all support ordinary equality comparisons but not <, <=, >, or >= comparisons. So a regular `WHERE col = 1` would be able to use a `_like` index. See: https://www.postgresql.org/docs/current/indexes-opclass.html But it's still interesting that the query planner al

Re: Proposal to not implicitly create varchar/text-pattern opclass indexes on PostgreSQL

2020-04-14 Thread Adam Johnson
Yes that one is odd. Looking more closely, django-oauth-toolkit doesn't make any LIKE queries, and doesn't seem to ever have done so. It seems rather that PostgreSQL is using the index to fulfill the unique constraint, as the corresponding '_uniq' index is not being touched: core=> select indexrel

Re: Proposal to not implicitly create varchar/text-pattern opclass indexes on PostgreSQL

2020-04-14 Thread charettes
Makes we wonder under which circumstances an OAuth token would need to be looked up using LIKE. I would expect the unique b-tree index which covers exact lookups to be sufficient. Simon Le mardi 14 avril 2020 09:01:48 UTC-4, Adam Johnson a écrit : > > For some numbers: I just checked on a long-

Re: Proposal to not implicitly create varchar/text-pattern opclass indexes on PostgreSQL

2020-04-14 Thread Adam Johnson
For some numbers: I just checked on a long-running client project using PostgreSQL, and it looks like several of the *_like indexes are in use: core=> select right(indexrelname, 10), idx_tup_read, idx_tup_fetch from pg_stat_all_indexes where indexrelname like '%_like' order by 1; right| id

Re: Proposal to not implicitly create varchar/text-pattern opclass indexes on PostgreSQL

2020-04-14 Thread Hannes Ljungberg
Thanks for your reply Tim, I also fail to see a "clean" upgrade path. The way I’ve been thinking of, is to just as you wrote, keep the code for deletion of the index so people who migrate to the Index-class will get it removed properly. Since it uses `IF EXISTS` it should be future-proof. We co

Re: Proposal to not implicitly create varchar/text-pattern opclass indexes on PostgreSQL

2020-04-13 Thread Tim Graham
I have some sympathy for this issue as I'm trying to make the createcachetable management command use SchemaEditor rather than some custom SQL construction logic*. The related problem I ran into is that the primary key column (a CharField) uses unique=True which means those undesired opclasses

Proposal to not implicitly create varchar/text-pattern opclass indexes on PostgreSQL

2020-04-12 Thread Hannes Ljungberg
Hi all, I would like to continue the discussion started in this very old thread: https://groups.google.com/d/msg/django-developers/H2QFcQYsbo8/RmRb-8FVypwJ I’m sorry if I should've continued the discussion in that thread but it felt a bit wrong to bring a 5 year old thread back to life :-) Any