| From: | Josh Berkus <josh(at)agliodbs(dot)com> |
|---|---|
| To: | Christopher Smith <christopherl_smith(at)yahoo(dot)com>, pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: query speed joining tables |
| Date: | 2003-01-13 21:47:49 |
| Message-ID: | 200301131347.49013.josh@agliodbs.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Christopher Smith | 2003-01-13 21:56:42 | Re: query speed joining tables |
| Previous Message | Christopher Smith | 2003-01-13 21:20:52 | query speed joining tables |