Re: [HACKERS] Surjective functional indexes
От | Konstantin Knizhnik |
---|---|
Тема | Re: [HACKERS] Surjective functional indexes |
Дата | |
Msg-id | b2d91183-289d-f6e4-1366-1864a3503a6e@postgrespro.ru обсуждение исходный текст |
Ответ на | Re: [HACKERS] Surjective functional indexes (Simon Riggs <simon@2ndquadrant.com>) |
Ответы |
Re: [HACKERS] Surjective functional indexes
|
Список | pgsql-hackers |
On 14.09.2017 18:53, Simon Riggs wrote: > It's not going to work, as already mentioned above. Those stats are at > table level and very little to do with this particular index. > > But you've not commented on the design I mention that can work: index relcache. > >> Concerning your idea to check cost of index function: it certainly makes >> sense. >> The only problems: I do not understand now how to calculate this cost. >> It can be easily calculated by optimizer when it is building query execution >> plan. >> But inside BuildIndexInfo I have just reference to Relation and have no idea >> how >> I can propagate here information about index expression cost from optimizer. > We could copy at create index, if we took that route. Or we can look > up the cost for the index expression and cache it. > > > Anyway, this is just jumping around because we still have a parameter > and the idea was to remove the parameter entirely by autotuning, which > I think is both useful and possible, just as HOT itself is autotuned. > Attached please find yet another version of the patch. I have to significantly rewrite it, because my first attempts to add auto-tune were not correct. New patch does it in correct way (I hope) and more efficiently. I moved auto-tune code from BuildIndexInfo, which is called many times, including heap_update (so at least once per update tuple). to RelationGetIndexAttrBitmap which is called only when cached RelationData is filled by backend. The problem with my original implementation of auto-tune was that switching off "projection" property of index, it doesn't update attribute masks, calculated by RelationGetIndexAttrBitmap. I have also added check for maximal cost of indexed expression. So now decision whether to apply projection index optimization (compare old and new values of indexed expression) is based on three sources: 1. Calculated hot update statistic: we compare number of hot updates which are performed because projection index check shows that index expression is not changed with total number of updates affecting attributes used in projection indexes. If it is smaller than some threshold (10%), then index is considered as non-projective. 2. Calculated cost of index expression: if it is higher than some threshold (1000) then extra comparison of index expression values is expected to be too expensive. 3. "projection" index option explicitly set by user. This setting overrides 1) and 2) -- Konstantin Knizhnik Postgres Professional: http://www.postgrespro.com The Russian Postgres Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Вложения
В списке pgsql-hackers по дате отправления: