Here's the WIP patch for doing prereading when doing bitmap index scans.

I was performance testing it as I was developing it here:

Note that this only kicks in for bitmap index scans which are kind of tricky
to generate. I used the attached function to generate them in the post above.

Also note I wouldn't expect to see much benefit unless you're on a raid array,
even a small one. But if you are on a raid array then the benefit should be
immediately obvious or else posix_fadvise just isn't working for you. I would
be interested in hearing on which OSes it does or doesn't work. 

*If* this is the approach we want to take rather than restructure the buffer
manager to avoid taking two trips by marking the buffer i/o-in-progress and
saving the pinned buffer in the bitmap heap scan then this is more or less in
final form. Aside from some autoconf tests and the documentation for the GUC I
think it's all in there.

Attachment: bitmap-preread-v5.diff.gz
Description: Binary data

#include <postgres.h>
#include <catalog/pg_type.h>
#include <utils/array.h>



  int32 n = PG_GETARG_INT32(0);
  int32 lobound = PG_GETARG_INT32(1);
  int32 hibound = PG_GETARG_INT32(2);
  Datum *elems 	= palloc(sizeof(Datum) * n);
  ArrayType *retval;
  int i;
  for (i=0; i<n; i++)
    elems[i]	= (int32)random()%(hibound-lobound+1)+lobound;

  retval = construct_array(elems, n, INT4OID, 4, true, 'i');

  Gregory Stark
  Ask me about EnterpriseDB's RemoteDBA services!
---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at


Reply via email to