I had just analyzed the dealergroupgeochache table. Wow. Thank you. That did the trick. Can you give me an explanation of the default_stats work? I don't think I completely understand what it means when you set it to 500 instead of 1000? thanks -----Original Message----- From: pgsql-performance-owner@xxxxxxxxxxxxxx [mailto:pgsql-performance-owner@xxxxxxxxxxxxxx] On Behalf Of Josh Berkus Sent: Friday, October 29, 2010 2:10 PM To: pgsql-performance@xxxxxxxxxxxxxx Subject: Re: Slow Query- Bad Row Estimate On 10/29/10 1:54 PM, Ozer, Pam wrote: > " -> Index Scan using dealergroupgeocache_i01 on > dealergroupgeocache (cost=0.00..5719.56 rows=9055 width=10) (actual > time=0.015..87.689 rows=163491 loops=1)" This appears to be your problem here. a) when was dealergroupgeocache last ANALYZED? b) try increasing the stats_target on dealergroupid and regionid, to say 500 and re-analyzing. -- -- Josh Berkus PostgreSQL Experts Inc. http://www.pgexperts.com -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance