Unneeded index created with unique=True and db_index=False in TextField

2015-04-14 Thread Some Developer
Using Django 1.8, psycopg2 2.6 and PostgreSQL 9.4.1. I have a model with a models.TextField(unique=True, db_index=False, primary_key=False) field in it. I understand that an index is created because of the comment shown in this code: https://github.com/django/django/blob/master/django/db/ba

Re: Unneeded index created with unique=True and db_index=False in TextField

2015-04-14 Thread Tommy Beadle
I believe that Postgres will *always* create an index on a column with a UNIQUE constraint. regression=> create table yo (id serial primary key, blah varchar(32) unique); CREATE TABLE regression=> \d yo Table "public.yo" Column | Type | Modifiers -

Re: Unneeded index created with unique=True and db_index=False in TextField

2015-04-14 Thread Curtis Maloney
Was the OP referring to the unique index, or the index created for the LIKE lookups? I was involved in a discussion recently [was there something on list too?] wanting to be able to opt-out of the second index because they knew they didn't need it, and it was _huge_ on their database. -- C On 1

Re: Unneeded index created with unique=True and db_index=False in TextField

2015-04-14 Thread Alex Hill
I agree this is a bug, and I think it's independent of the discussion of customisable indexes. Postgres creates the necessary index for unique constraints automatically as Tommy said. I'm guessing other backends do too, because the explicit index creation DDL is omitted when unique is True in t

Re: Unneeded index created with unique=True and db_index=False in TextField

2015-04-15 Thread Some Developer
On 15/04/15 03:37, Curtis Maloney wrote: Was the OP referring to the unique index, or the index created for the LIKE lookups? I was involved in a discussion recently [was there something on list too?] wanting to be able to opt-out of the second index because they knew they didn't need it, and it

Re: Unneeded index created with unique=True and db_index=False in TextField

2015-04-15 Thread Tim Graham
#19441 is the ticket where it was decided that unique=True implies a database index. The documentation says, "Note that when ``unique`` is ``True``, you don't need to specify`Field.db_index`, because ``unique`` implies the creation of an index." Unless we decide that is wrong, I think the cor

Re: Unneeded index created with unique=True and db_index=False in TextField

2015-04-15 Thread Some Developer
On 15/04/15 18:22, Tim Graham wrote: #19441 is the ticket where it was decided that unique=True implies a database index. The documentation says, "Note that when ``unique`` is ``True``, you don't need to specify `Field.db_index`, because ``unique`` implies the creation of an index." Understo

Re: Unneeded index created with unique=True and db_index=False in TextField

2015-04-15 Thread Kevin Christopher Henry
This issue was the subject of https://code.djangoproject.com/ticket/24082. There, the accepted (but not implemented) solution is the same as suggested here: allowing the user to opt out of the creation of the additional index with `db_index=False`. On Wednesday, April 15, 2015 at 2:11:25 PM UTC

Re: Unneeded index created with unique=True and db_index=False in TextField

2015-04-15 Thread Some Developer
On 15/04/15 23:45, Kevin Christopher Henry wrote: This issue was the subject of https://code.djangoproject.com/ticket/24082. There, the accepted (but not implemented) solution is the same as suggested here: allowing the user to opt out of the creation of the additional index with `db_index=False