Re: Slow query but can't see whats wrong

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Henrik Zagerholm <henke(at)mac(dot)se>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Slow query but can't see whats wrong
Date: 2007-07-24 14:10:32
Message-ID: 8837.1185286232@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Henrik Zagerholm <henke(at)mac(dot)se> writes:
> I'm using pgsql 8.2.4 and I have this query which is sooo slow but I
> can seem to figure out why.

Seems the core of the problem is the misestimation here:

> " -> Index Scan using
> tbl_file_idx on tbl_file (cost=0.01..8.34 rows=1 width=39) (actual
> time=0.283..3339.003 rows=25039 loops=1)"
> " Index Cond: ((lower
> ((file_name)::text) ~>=~ 'awstats'::character varying) AND (lower
> ((file_name)::text) ~<~ 'awstatt'::character varying))"
> " Filter: (lower
> ((file_name)::text) ~~ 'awstats%'::text)"

Looks like either your stats are not up to date on this table, or you
need to increase the stats target for file_name. Anytime a scan row
estimate is off by a factor of 25000, you're going to get a bad plan :-(

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message A. Kretschmer 2007-07-24 14:11:02 Re: regexp_replace
Previous Message Gregory Stark 2007-07-24 14:05:19 Re: varchar does not work too well with IS NOT NULL partial indexes.