gin index postgres 9.2 - Mailing list pgsql-general

From Lucas Possamai
Subject gin index postgres 9.2
Date
Msg-id CAE_gQfW4j+CUHcPyzrmx4eJiwv8rUMS2-yPgAGhEso15ecNxmQ@mail.gmail.com
Whole thread Raw
Responses Re: gin index postgres 9.2
List pgsql-general

I've got the following query:

SELECT COUNT(DISTINCT j0_.id) AS sclr0
FROM ja_customers j0_
WHERE ((LOWER(j0_.name_first) LIKE '%asd%'       OR LOWER(j0_.name_last) LIKE '%asd%'       OR LOWER(j0_.company) LIKE '%asd%'       OR LOWER(j0_.phone) LIKE '%asd%'       OR LOWER(j0_.mobile) LIKE '%asd%')      AND j0_.deleted = 'f'      AND j0_.clientid = 2565) AND j0_.clientid = 2565

It returns: 3

I created a GIN index;

CREATE INDEX CONCURRENTLY ON public.ja_customers USING gin (name_first gin_trgm_ops, name_last gin_trgm_ops, company gin_trgm_ops, phone gin_trgm_ops, mobile gin_trgm_ops);

New query to hit the new index:

SELECT COUNT(DISTINCT j0_.id) AS sclr0
FROM ja_customers j0_
WHERE j0_.name_first LIKE '%asd%'       OR j0_.name_last LIKE '%asd%'       OR j0_.company LIKE '%asd%'       OR j0_.phone LIKE '%asd%'       OR j0_.mobile LIKE '%asd%'      AND j0_.deleted = 'f'      AND j0_.clientid = 2565 AND j0_.clientid = 2565

It returns: 532


The problem is that the new query returns different results...

Please, what am I missing guys?


Cheers

pgsql-general by date:

Previous
From: Jeff Janes
Date:
Subject: Re: archive_command during database shutdown
Next
From: "David G. Johnston"
Date:
Subject: Re: gin index postgres 9.2