Re: 500x speed-down: Wrong query plan?

От: Tom Lane
Тема: Re: 500x speed-down: Wrong query plan?
Дата: ,
Msg-id: 6914.1136833010@sss.pgh.pa.us
(см: обсуждение, исходный текст)
Ответ на: Re: 500x speed-down: Wrong query plan?  (Alessandro Baretta)
Ответы: Re: 500x speed-down: Wrong statistics!  (Alessandro Baretta)
Список: pgsql-performance

Скрыть дерево обсуждения

500x speed-down: Wrong query plan?  (Alessandro Baretta, )
 Re: 500x speed-down: Wrong query plan?  (Matteo Beccati, )
  Re: 500x speed-down: Wrong query plan?  (Alessandro Baretta, )
   Re: 500x speed-down: Wrong query plan?  (Tom Lane, )
    Re: 500x speed-down: Wrong query plan?  (Alessandro Baretta, )
     Re: 500x speed-down: Wrong query plan?  (Tom Lane, )
      Re: 500x speed-down: Wrong statistics!  (Alessandro Baretta, )
       Re: 500x speed-down: Wrong statistics!  (Tom Lane, )
        Re: 500x speed-down: Wrong statistics!  (Alessandro Baretta, )
 Re: 500x speed-down: Wrong query plan?  (Jaime Casanova, )

Alessandro Baretta <> 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 по дате сообщения:

От: Bruce Momjian
Дата:
Сообщение: Re: [PERFORMANCE] Beetwen text and varchar field
От: Andrea Arcangeli
Дата:
Сообщение: NOT LIKE much faster than LIKE?