Re: Is a better way to have the same result of this - Mailing list pgsql-performance

From Tomasz Myrta
Subject Re: Is a better way to have the same result of this
Date
Msg-id 3DEFAAF7.6040000@klaster.net
Whole thread Raw
In response to Re: Is a better way to have the same result of this  (Vernon Wu <vernonw@gatewaytech.com>)
List pgsql-performance
Vernon Wu wrote:

 > Ron,
 >
 > The gender is indexed. Each user has account and preference, but not
necessary block.


Indexing on gender won't speed up your query - it can even slow it down.
You have probably 50% of "f" and 50% of "m". Using index on gender will
divide your potential answers by 2. Make index on columns, which
excludes much more useless rows.
I think you can create index on:
- block/personid
- profile/userid

I read in Postgres documentation(but didn't try) that you can also
change "id NOT IN (select id" to "not exists select * where id=". It may
help also.

Do user have more than one account or preference?
If no, you can change "not in" into "inner/outer join" which are the
best ones.

Regards,
Tomasz Myrta


pgsql-performance by date:

Previous
From: Vernon Wu
Date:
Subject: Re: Is a better way to have the same result of this
Next
From: Jean-Luc Lachance
Date:
Subject: Re: Is a better way to have the same result of this