Re: 500x speed-down: Wrong query plan? - Mailing list pgsql-performance

From Tom Lane
Subject Re: 500x speed-down: Wrong query plan?
Date
Msg-id 6914.1136833010@sss.pgh.pa.us
Whole thread Raw
In response to Re: 500x speed-down: Wrong query plan?  (Alessandro Baretta <a.baretta@barettadeit.com>)
Responses Re: 500x speed-down: Wrong statistics!  (Alessandro Baretta <a.baretta@barettadeit.com>)
List pgsql-performance
Alessandro Baretta <a.baretta@barettadeit.com> writes:
> Tom Lane wrote:
>> I'm curious to see how many rows the planner thinks this will produce,
>> and whether it will use the index or not.

> dmd-freerp-1-alex=# EXPLAIN ANALYZE SELECT * FROM articolo WHERE
> articolo.xdbs_modified > '2006-01-08 18:25:00+01';
>                                                                  QUERY PLAN
>
-------------------------------------------------------------------------------------------------------------------------------------------
>   Index Scan using articolo_modified_index on articolo  (cost=0.00..3914.91
> rows=17697 width=653) (actual time=0.032..0.032 rows=0 loops=1)
>     Index Cond: (xdbs_modified > '2006-01-08 18:25:00'::timestamp without time zone)
>   Total runtime: 0.150 ms
> (3 rows)

Well, there's your problem: 17697 rows estimated vs 0 actual.  With a
closer row estimate it would've probably done the right thing for the
join problem.

How many rows are really in the table, anyway?  Could we see the
pg_stats row for articolo.xdbs_modified?

            regards, tom lane

pgsql-performance by date:

Previous
From: Chris Hoover
Date:
Subject: Memory Usage Question
Next
From: "Luke Lonergan"
Date:
Subject: Re: help tuning queries on large database