btree: downlink right separator/HIKEY optimization
От | Matthias van de Meent |
---|---|
Тема | btree: downlink right separator/HIKEY optimization |
Дата | |
Msg-id | CAEze2WijWhCQy_nZVP4Ye5Hwj=YW=3rqv+hbMJGcOHtrYQmyKw@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: btree: downlink right separator/HIKEY optimization
Re: btree: downlink right separator/HIKEY optimization |
Список | pgsql-hackers |
(now really to -hackers) Hi, Over at [0] I'd implemented an optimization that allows us to skip calling _bt_compare in _bt_moveright in many common cases. This patch, when stacked on top of the prefix truncation patch, improves INSERT performance by an additional 2-9%pt, with an extreme case of 45% in the worscase index tests at [0]. The optimization is that we now recognze that our page split algorithm all but guarantees that the HIKEY matches this page's downlink's right separator key bytewise, excluding the data stored in the IndexTupleData struct. By caching the right separator index tuple in _bt_search, we can compare the downlink's right separator and the HIKEY, and when they are equal (memcmp() == 0) we don't have to call _bt_compare - the HIKEY is known to be larger than the scan key, because our key is smaller than the right separator, and thus transitively also smaller than the HIKEY because it contains the same data. As _bt_compare can call expensive user-provided functions, this can be a large performance boon, especially when there are only a small number of column getting compared on each page (e.g. index tuples of many 100s of bytes, or dynamic prefix truncation is enabled). By adding this, the number of _bt_compare calls per _bt_search is often reduced by one per btree level. Kind regards, Matthias van de Meent Neon (https://neon.tech) PS. Best served with dynamic prefix truncation [1] and btree specialization [0]. [0] https://www.postgresql.org/message-id/CAEze2WiqOONRQTUT1p_ZV19nyMA69UU2s0e2dp+jSBM=j8snuw@mail.gmail.com [1] https://www.postgresql.org/message-id/flat/CAEze2Wh-h20DmPSMXp4qHR0-ykh9=Z3ejX8MSsbikbOqaYe_OQ@mail.gmail.com
Вложения
В списке pgsql-hackers по дате отправления: