Re: Avoid full GIN index scan when possible

Поиск
Список
Период
Сортировка
От Alexander Korotkov
Тема Re: Avoid full GIN index scan when possible
Дата
Msg-id CAPpHfdsXN5iq3rUwjuwtp_GRFmhq+1QAtgiywGM_6YM9PdGdMg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Avoid full GIN index scan when possible  (Nikita Glukhov <n.gluhov@postgrespro.ru>)
Ответы Re: Avoid full GIN index scan when possible  (Alexander Korotkov <a.korotkov@postgrespro.ru>)
Список pgsql-hackers
On Sat, Nov 23, 2019 at 2:39 AM Nikita Glukhov <n.gluhov@postgrespro.ru> wrote:
> Attached 8th version of the patches.

I've read this thread.  I decided to rewrite the patch in the way,
which I find simple and more clear.  Attached is the draft patch
written from scratch except regression tests, which were copied "as
is".  It based on the discussion in this thread as well as my own
ideas.  It works as following.

1) New GinScanKey->excludeOnly flag is introduced.  This flag means
that scan key might be satisfied even if no of its entries match the
row.  So, such scan keys are useful only for additional check of
results returned by other keys.  That is excludeOnly scan key is
designed for exclusion of already obtained results.
2) Initially no hidden scan entries are appended to
GIN_SEARCH_MODE_ALL scan keys.  They are appended after getting
statistics about search modes applied to particular attributes.
3) We append at only one GIN_CAT_EMPTY_QUERY scan entry when all scan
keys GIN_SEARCH_MODE_ALL.  If there is at least one normal scan key,
no GIN_CAT_EMPTY_QUERY is appended.
4) No hidden entries are appended to GIN_SEARCH_MODE_ALL scan key if
there are normal scan keys for the same column.  Otherwise
GIN_CAT_NULL_KEY hidden entry is appended.
5) GIN_SEARCH_MODE_ALL scan keys, which don't have GIN_CAT_EMPTY_QUERY
hidden entry, are marked with excludeOnly flag.  So, they are used to
filter results of other scan keys.
6) GIN_CAT_NULL_KEY hidden entry is found, then scan key doesn't match
independently on result of consistent function call.

Therefore, attached patch removes unnecessary GIN_CAT_EMPTY_QUERY scan
entries without removing positive effect of filtering in
GIN_SEARCH_MODE_ALL scan keys.

Patch requires further polishing including comments, minor refactoring
etc.  I'm going to continue work on this.

------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Вложения

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

Предыдущее
От: Mahendra Singh
Дата:
Сообщение: Re: relpages of btree indexes are not truncating even after deletingall the tuples from table and doing vacuum
Следующее
От: "tsunakawa.takay@fujitsu.com"
Дата:
Сообщение: RE: Implementing Incremental View Maintenance