Re: another index question

Поиск
Список
Период
Сортировка
От ADBAAMD
Тема Re: another index question
Дата
Msg-id 3AC79D18.9010307@bell.ca
обсуждение исходный текст
Ответ на another index question  (Sean Harding <sharding@dogcow.org>)
Ответы Re: How do I...  (Paul Tomblin <ptomblin@xcski.com>)
Re: another index question  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Tom Lane wrote:

> OK, indeed this is a bug --- the planner has a bad interaction for LIMIT
> clauses used in "IN" subselects.  Will fix.
>
> You could avoid the bug, and get a better plan at the top level anyway,
> by writing
>
> SELECT frm,rcpt,subject FROM mesg_headers WHERE mesgnum = (SELECT mesgnum
> FROM mesg_headers ORDER BY mesgnum DESC LIMIT 1);
>
> Since you know the subselect is going to produce exactly one tuple,
> there's no need to use IN.

    I don't know if this is a generic database issue, an SQL one, of pgsql's;
but wasn't relational invented so that we shouldn't need to fine tune
access paths?

    More to the point, shouldn't the statistics on tables plus the syntax be
enough for the planner to get this (not so complex) query a good plan,
even if not optimal?

    And if needed shouldn't we get away with hints or something like that
instead of rewriting?

    Sorry for the basic questions, I'm trying to learn.  No criticism of
anyone's work intended, just a general question.



--
  _
/ \   Leandro Guimarães Faria Corsetti Dutra         +55 (11) 3040 8913
\ /   Amdocs at Bell Canada                          +1 (514) 786 87 47
  X    Support Center, São Paulo, Brazil          mailto:adbaamd@bell.ca
/ \   http://terravista.pt./Enseada/1989/    mailto:leandrod@amdocs.com



В списке pgsql-general по дате отправления:

Предыдущее
От: Joel Burton
Дата:
Сообщение: Can I get the default value for an attribute (field) ?
Следующее
От: Paul Tomblin
Дата:
Сообщение: Re: Ok, why isn't it using *this* index?