pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kaufhold, Christian (LFD) <Christian.Kaufhold@blfd.bayern.de>
Cc: pgsql-performance@postgresql.org
Subject: Re: Query slow after analyse on postgresql 8.2
Date: Thu, 17 Jun 2010 10:58:36 -0400
Message-ID: <3775.1276786716@sss.pgh.pa.us> (raw)
In-Reply-To: <0694BCCA1B37BE4B8FEB01807799BD540142B47F@BLFD_2.lfd.bayern.de>
References: <0694BCCA1B37BE4B8FEB01807799BD540142B47F@BLFD_2.lfd.bayern.de>

"Kaufhold, Christian (LFD)" <Christian.Kaufhold@blfd.bayern.de> writes:
> I have the following query that I run agains postgresql 8.2:
> ...
> But when I run analyse the same query runs for hours.

Seems like the core of the problem is here:

>                                                               ->  Seq
> Scan on massnahmeobjekt m  (cost=0.00..3271.88 rows=1 width=94) (actual
> time=0.387..577.771 rows=3694 loops=1)
> Filter: ((aktennummer)::text ~* 'M\\-2009\\-1'::text)

If that rowcount estimate weren't off by three orders of magnitude you
probably would be getting a more appropriate plan.  The first thing you
could try is increasing the statistics target for aktennummer.  Also,
if you're running in a non-C locale and this is 8.2.5 or older, try a
more recent 8.2.x.  Updating to 8.3 or 8.4 might help even more.

			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <3775.1276786716@sss.pgh.pa.us>
Permalink:  ../3775.1276786716@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3775.1276786716@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, Christian.Kaufhold@blfd.bayern.de
  Subject: Re: Query slow after analyse on postgresql 8.2
  In-Reply-To: <3775.1276786716@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox