Re: B-Tree support function number 3 (strxfrm() optimization)
От | Peter Geoghegan |
---|---|
Тема | Re: B-Tree support function number 3 (strxfrm() optimization) |
Дата | |
Msg-id | CAM3SWZThi7iZEAhQHMdGDBFCLafSwbYU8QVDBEkz84O2Qqfc1g@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: B-Tree support function number 3 (strxfrm() optimization) (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: B-Tree support function number 3 (strxfrm() optimization)
|
Список | pgsql-hackers |
On Mon, Mar 31, 2014 at 1:30 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote: > Possibly worth noting is that on my RHEL6 and Fedora machines, > "man strxfrm" says the same thing as the POSIX spec. Likewise on OS X. > I don't think we can rely on what you suggest. Okay. Attached revision only trusts strxfrm() blobs (as far as that goes) when the buffer passed to strxfrm() was sufficiently large that the blob could fully fit. We're now managing two buffers as part of the text sort support state (for leading poor man's keys, rather than just for non-leading keys as before) - one for the original string (to put in a NULL byte, since like strcoll(), strxfrm() expects that), and the other to temporarily store the blob before memcpy()ing over to the pass-by-value poor man's normalized key Datum. These are the same two persistent sortsupport-state buffers used when sorting a non-leading text key, where there is one for each string that needs to have a NULL byte appended. This appears to perform at least as well as the prior revision, and possibly even appreciably better. I guess that glibc was internally managing a buffer to do much the same thing, so perhaps we gain something more from mostly avoiding that with a longer lived buffer. Perhaps you could investigate the performance of this new revision too, Thom? I'd really like to see this basic approach expanded to store pseudo leading keys in internal B-Tree pages too, per my earlier proposals. At the very least, B-Tree index builds should benefit from this. I think I'm really only scratching the surface here, both in terms of the number of places in the code where a poor man's normalized key could usefully be exploited, as well as in terms of the number of B-Tree operator classes that could be made to provide one. -- Peter Geoghegan
Вложения
В списке pgsql-hackers по дате отправления: