Re: Query gets slow when where clause increases - Mailing list pgsql-performance

From Dennis Bjorklund
Subject Re: Query gets slow when where clause increases
Date
Msg-id Pine.LNX.4.44.0407012238120.21809-100000@zigo.dhs.org
Whole thread Raw
In response to Query gets slow when where clause increases  (James Antill <james@and.org>)
List 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


pgsql-performance by date:

Previous
From: James Antill
Date:
Subject: Query gets slow when where clause increases
Next
From: "Peter Alberer"
Date:
Subject: Mysterious performance of query because of plsql function in where condition