I'm doing a full-text search with a GIN index in Postgres (all localhost), and when I write my own query and run it in psql, I am getting great response times and `EXPLAIN ANALYZE` reports an index hit (woohoo), however when querying via the Django Admin search box with the **same search terms**, the index is not scanned and the query takes upwards of forever to complete.

My index is created thusly via the [fully-awesome pg\_trgm Postgres extension](http://www.depesz.com/2011/02/19/waiting-for-9-1-faster-likeilike/):

```
CREATE INDEX name_gin ON entity USING gin (name gin_trgm_ops);

```

This query hits the index and takes a blazing **84ms** to search through 900k full-text records:

```
SELECT COUNT(*) 
FROM entity 
WHERE name LIKE UPPER('%dubteeeff%') 
 AND name LIKE UPPER('%django%');

```

The exact same query, as created by the Django Admin interface, takes **938ms**:

```
SELECT COUNT(*) 
FROM entity 
WHERE UPPER("entity"."name"::text) LIKE UPPER('%dubteeeff%') 
  and UPPER("entity"."name"::text) LIKE UPPER('%django%');`

```

The only difference appears to be the way the columns are referenced--I'm fairly new with Django and Postgres--is there some Postgres config setting or Django admin QuerySet-something, or a RawQuery that I could override or modify to speed this up? I don't want my Admin page to at best be slow and at worst, drag the rest of the site down with it.

Thanks in advance.