Re: Query gets slow when where clause increases

From: Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org>
To: James Antill <james(at)and(dot)org>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Query gets slow when where clause increases
Date: 2004-07-01 20:44:22
Message-ID: Pine.LNX.4.44.0407012238120.21809-100000@zigo.dhs.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Tue, 29 Jun 2004, James Antill wrote:

> -> Index Scan using idx_ticket_groups_assigned on ticket_groups g (cost=0.00..241.76 rows=5 width=20) (actual time=0.13..12.67 rows=604 loops=1)
> Index Cond: (assigned_to = 1540)

Here the planner estimated that it would find 5 rows, but it did find 604.
I take that as a sign that you have not ran VACUUM ANALYZE recently?

If you done that, then maybe you need to change the statistics target for
that column. Before you set it on that column you could try to just alter
the default statistics target for one session like this:

SET default_statistics_target TO 100;
ANALYZE;

and then see if you get a better plan when you run the query afterwards.

If it helps you can either set the default_statistics_target in
postgresql.conf or set it just for some column using ALTER TABLE.

--
/Dennis Björklund

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Peter Alberer 2004-07-02 07:48:48 Mysterious performance of query because of plsql function in where condition
Previous Message Litao Wu 2004-07-01 16:12:47 network address query