[postgis-devel] Avoid unnecessary memory copy in gserialized_datum_get_box2df_p

Yuto HAYAMIZU yuto at hayamiz.com
Tue Oct 1 08:49:18 PDT 2013


Hi,

This is my first post to postgis-devel ML, and I attached a small
performance improvement patch.
In gserialized_datum_get_box2df_p, PG_DETOAST_DATUM_SLICE is always called
for obtaining header section of the gserialized datum.
PG_DETOAST_DATUM_SLICE always performs memory allocation and copy, but
such memory operations are not necessary when the datum is not extended(
not external nor compressed ).
This patch removes such extra memory operations by just calling
PG_DETOAST_DATUM.

It can be applied to svn trunk and 2.0 branch. I have confirmed all
regression tests are passed with PostgreSQL 9.2.4.

I observed 11% performance improvement with a certain dataset.
Unfortunately details of the dataset cannot be disclosed, but it consists
of a table containing 10M records with a GiST-indexed geometry column and
a table containing polygons.
Tested query is like: SELECT count(*) FROM polygons, points WHERE
polygons.attr = XXX AND ST_Within(points.the_geom, polygons.the_geom);

Any thoughts?

----
Yuto HAYAMIZU
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-avoid-detoast-slicing-if-datum-is-not-extended.patch
Type: application/octet-stream
Size: 1223 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20131002/39a51b71/attachment.obj>


More information about the postgis-devel mailing list