Re: query speed joining tables

From: Christopher Smith <christopherl_smith(at)yahoo(dot)com>
To: josh(at)agliodbs(dot)com, pgsql-sql(at)postgresql(dot)org
Subject: Re: query speed joining tables
Date: 2003-01-13 21:56:42
Message-ID: 20030113215642.24981.qmail@web14103.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


I understand cachable functions but your proposed application is a little unclear.
is it possible to see an example?
thanks in advance.
Josh Berkus <josh(at)agliodbs(dot)com> wrote:
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

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
message can get through to the mailing list cleanly

---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tomasz Myrta 2003-01-13 22:01:39 Re: query speed joining tables
Previous Message Josh Berkus 2003-01-13 21:47:49 Re: query speed joining tables