Re: query speed joining tables
От | Josh Berkus |
---|---|
Тема | Re: query speed joining tables |
Дата | |
Msg-id | 200301131347.49013.josh@agliodbs.com обсуждение исходный текст |
Ответ на | query speed joining tables (Christopher Smith <christopherl_smith@yahoo.com>) |
Ответы |
Re: query speed joining tables
|
Список | 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 BerkusAglio Database SolutionsSan Francisco
В списке pgsql-sql по дате отправления: