All:

I'm not a Django developer, nor will I pretend to be.  But I did come across 
something I thought you should be aware of.

The django online documentation mentions that the SQL equivalent for  
__icontains is something like:

    SELECT ... WHERE headline ILIKE '%Lennon%';
However, for postgresql - one of the dbs that actually supports ILIKE - I 
noticed __icontains was actually performing something similar to:
    SELECT ... WHERE LOWER(headline) LIKE LOWER('%Lennon%');

The ILIKE is obviously much faster, so, I dug around a little and changed a 
line or two in these files:

/usr/local/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py
/usr/local/lib/python2.7/site-packages/django/db/backends/postgresql/operations.py

...so __icontains actually uses ILIKE instead, and it's running great.

OK:

1) Any reason I shouldn't have done that, performance wise?
2) Should this be changed in the codebase going forward?


thanks, and I hope this helps,
ted

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to