Re: Query 4-5 times slower after ANALYZE - Mailing list pgsql-general

From Gregory Stark
Subject Re: Query 4-5 times slower after ANALYZE
Date
Msg-id 878wn3f0wd.fsf@oxford.xeocode.com
Whole thread Raw
In response to Re: Query 4-5 times slower after ANALYZE  (Bill Moran <wmoran@potentialtech.com>)
List pgsql-general
Bill Moran <wmoran@potentialtech.com> writes:

> I opened one of those links figuring I'd take a few minutes to see if I could
> muster up some advice ... and just started laughing ... definitely not the
> type of query that one can even understand in just a few minutes!

You might consider setting default_statistics_target to 100 and re-analyzing.
The estimates don't look too far off but like Bill I haven't analyzed it very
carefully.

One other things that stands out, using comparisons like
 ('now'::date - creation_date) >= <expression>

is going to make it hard to optimize. Better to use something like
 creation_date <= now() - <expression>

Both because of the now() instead of 'now'::date and because the latter is a
comparison that can be indexed instead of an expression which could use an
index on creation_date.


--
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com
  Ask me about EnterpriseDB's On-Demand Production Tuning

pgsql-general by date:

Previous
From: Sanjay Arora
Date:
Subject: Re: postgreSQL & amazon ec2 cloud
Next
From: tv@fuzzy.cz
Date:
Subject: Re: Query 4-5 times slower after ANALYZE