From: Josh Berkus <josh@agliodbs.com>
To: Christopher Smith <christopherl_smith@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: Re: query speed joining tables
Date: Mon, 13 Jan 2003 13:47:49 -0800
Message-ID: <200301131347.49013.josh@agliodbs.com> (raw)
In-Reply-To: <20030113212052.60493.qmail@web14107.mail.yahoo.com>
References: <20030113212052.60493.qmail@web14107.mail.yahoo.com>
Chris,
Here are probably your two main query problems:
> strpos(user_match_details.ethnicity,'Asian') !=0 AND
It is impossible for Postgres to use an index for the above as it is written.
I would suggest one of two improvements;
1) Modify the schema so that multiple ethnicity details are kept in a
sub-table rather than a free-form text field you have to search, or:
2) Create a cachable function for "contains_asian" and index on that.
> user_details_p.zipcode in (select zips_max.destination from zips_max where
zips_max.origin='90210' )
> order by user_login.last_login desc;
Use a "WHERE EXISTS" clause instead of "IN".
--
-Josh Berkus
Aglio Database Solutions
San Francisco
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: josh@agliodbs.com, christopherl_smith@yahoo.com
Subject: Re: query speed joining tables
In-Reply-To: <200301131347.49013.josh@agliodbs.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox