[BUGS] Re: Query planner skipping index depending on DISTINCT parameterorder (2)

Поиск
Список
Период
Сортировка
От Дилян Палаузов
Тема [BUGS] Re: Query planner skipping index depending on DISTINCT parameterorder (2)
Дата
Msg-id 6e8b3a9b-9b3d-e655-4456-f91a1ea3292b@aegee.org
обсуждение исходный текст
Ответ на [BUGS] Re: Query planner skipping index depending on DISTINCT parameterorder (2)  (Greg Stark <stark@mit.edu>)
Ответы [BUGS] Re: Query planner skipping index depending on DISTINCT parameterorder (2)  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Список pgsql-bugs
Hello,

for the record, in this table

spamassassin=> \d bayes_token           Table "public.bayes_token"  Column    Type            Modifiers
────────── ─────── ────────────────────────────
id         integer not null default 0
token      bytea   not null default '\x'::bytea
spam_count integer not null default 0
ham_count  integer not null default 0
atime      integer not null default 0
Indexes:    "bayes_token_pkey" PRIMARY KEY, btree (id, token)    "bayes_token_idx1" btree (token)


"SELECT id, token FROM bayes_token" and "SELECT id, token FROM bayes_token WHERE id > 0" do Seq Scan and need 35-50
Sec.

But "SELECT id, token FROM bayes_token WHERE id > 1" uses Index Only Scan and 0.04 seconds on pg 9.6.5 .

Greetings  Dilian

On 09/25/17 12:43, Greg Stark wrote:
> On 17 September 2017 at 18:15, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> 
>> For plain DISTINCT, yeah we could consider other orderings ... but
>> we're rather unlikely to find an index that matches all the output
>> columns, regardless of what order they're in.  So it's just not that
>> exciting.
> 
> I don't follow this part. Are you saying a simple "select distinct a,b
> from table" is unlikely to find a matching index on <b,a>? Don't we
> already do exactly this for "select a,b from table group by a,b"? I
> would have expected the two equivalent SQL statements to use exactly
> the same infrastructure and thought it was only a matter of historical
> legacy that they didn't.
> 


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [BUGS] BUG #14828: Security isn't working
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: [BUGS] BUG #14825: enum type: unsafe use?