From: | Atsushi Ogawa <atsushi(dot)ogawa(at)gmail(dot)com> |
---|---|
To: | pgsql-patches(at)postgresql(dot)org |
Subject: | Space management for PGresult |
Date: | 2005-11-23 07:21:12 |
Message-ID: | 613787150511222321u75c657c5i@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-patches |
In space management for PGresult of libpq, the block size of PGresult
is always PGRESULT_DATA_BLOCKSIZE(2048bytes). Therefore, when a large
result of query is received, malloc is executed many times.
My proposal is to enlarge the size of the block whenever the block is
allocated. The size of first block is PGRESULT_DATA_BLOCKSIZE. And the
size of the following blocks will be doubled until it reaches
PGRESULT_MAX_DATA_BLOCKSIZE.
PGRESULT_MAX_DATA_BLOCKSIZE is new constants. I think that 2Mbytes is
good enough for this constants.
The test result is the following:
Test SQL:
select * from accounts; (It is pgbench's table. scale factor is 10.)
The number of malloc calls at pqResultAlloc:
8.1.0 : 80542
patched: 86
Execution time:
8.1.0 : 6.80 sec
patched: 6.73 sec
regards,
--- Atsushi Ogawa
Attachment | Content-Type | Size |
---|---|---|
libpq_alloc.patch | application/octet-stream | 5.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tatsuo Ishii | 2005-11-23 13:24:00 | Re: [PATCHES] Patch to allow contrib/pgbench files to have blank |
Previous Message | Mark Kirkwood | 2005-11-23 04:52:36 | Re: TODO Item - Add system view to show free space map |