Re: Poor query performance
Re: Poor query performance
От:
Alex <alex@liivid.com>
Дата:
Forgot to add: postgres@ec2-75-101-128-4:~$ psql --version psql (PostgreSQL) 8.3.5
Re: Poor query performance
От:
Greg Stark <gsstark@mit.edu>
Дата:
On Thu, Jul 9, 2009 at 10:35 PM, Alex wrote: > Forgot to add: > > postgres@ec2-75-101-128-4:~$ psql --version > psql (PostgreSQL) 8.3.5 How is the index sl_city_etc defined? -- greg http://mit.edu/~gsstark/resume.pdf
Re: Poor query performance
От:
Greg Stark <gsstark@mit.edu>
Дата:
On Wed, Jul 15, 2009 at 8:51 AM, Alex wrote: > Also posted this to the list. Thanks for your answer - still > struggling. Staying on-list is always preferred. >> How is the index sl_city_etc defined? > > Index "public.sl_city_etc" > Column | Type > --------------+----------------------------- > city | text > listing_type | text > post_time | timestamp without time zone > bedrooms | integer > region | text > geo_lat | integer > geo_lon | integer > btree, for table "public.source_listings" So the presence of listing_type before post_time when it's not in your query means that the index scan has to look at every entry for 'boston'. It skips over entries that don't match the post_time or geo columns but it still has to go through them in the index. Think of being asked to find every word in the dictionary starting with 'a' and whose third letter is 'k' but with no restriction on the second letter... You would probably be better off starting with separate indexes on each column and then considering how to combine them if possible than starting with them all in one index like this. If you always have city in your query and then some collection of other columns then you could have separate indexes on , , , etc. The geometric columns are a more interesting case. You could have separate indexes on each and hope a bitmap scan combines them, or you could use a geometric GIST index on point(geo_lon,geo_lat). Doing so would mean using the right operator to find points within a box rather than simple < and > operators. -- greg http://mit.edu/~gsstark/resume.pdf
Re: Poor query performance
От:
Alex <alex@liivid.com>
Дата:
>
> How is the index sl_city_etc defined?
>
Index "public.sl_city_etc"
Column | Type
--------------+-----------------------------
city | text
listing_type | text
post_time | timestamp without time zone
bedrooms | integer
region | text
geo_lat | integer
geo_lon | integer
btree, for table "public.source_listings"