Fix performance problem when building a lossy tidbitmap.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: 6016005118295fdcd97d99a0f372f18a28251c48
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2011-08-20T18:51:52Z
Releases: 8.2.22
Fix performance problem when building a lossy tidbitmap.

As pointed out by Sergey Koposov, repeated invocations of tbm_lossify can
make building a large tidbitmap into an O(N^2) operation.  To fix, make
sure we remove more than the minimum amount of information per call, and
add a fallback path to behave sanely if we're unable to fit the bitmap
within the requested amount of memory.

This has been wrong since the tidbitmap code was written, so back-patch
to all supported branches.

Files

PathChange+/−
src/backend/nodes/tidbitmap.c modified +19 −3