OSDN Git Service

Further examination of ltsReleaseBlock usage shows that it's got a
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 7 Mar 2006 23:46:24 +0000 (23:46 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 7 Mar 2006 23:46:24 +0000 (23:46 +0000)
commit43ceb3d4493dc7bcd9a32302b04bd31f1f0edffc
tree3137dff634c114af3681217376f89bf97b629744
parent8db05ba411ecd3ce2cb0cb7c78fec87658e1a4ab
Further examination of ltsReleaseBlock usage shows that it's got a
performance issue during regular merge passes not only the 'final merge'
case.  The original design contemplated that there would never be more
than about one free block per 'tape', hence no need for an efficient
method of keeping the free blocks sorted.  But given the later addition
of merge preread behavior in tuplesort.c, there is likely to be about
work_mem worth of free blocks, which is not so small ... and for that
matter the number of tapes isn't necessarily small anymore either.  So
we'd better get rid of the assumption entirely.  Instead, I'm assuming
that the usage pattern will involve alternation between merge preread
and writing of a new run.  This makes it reasonable to just add blocks
to the list without sorting during successive ltsReleaseBlock calls,
and then do a qsort() when we start getting ltsGetFreeBlock() calls.
Experimentation seems to confirm that there aren't many qsort calls
relative to the number of ltsReleaseBlock/ltsGetFreeBlock calls.
src/backend/utils/sort/logtape.c