Troubleshooting Functions
These functions are utilities for troubleshooting and repairing geometry data.
They are only needed if the geometry data is corrupted in some way,
which should never happen under normal circumstances.
PostGIS_AddBBox
Add bounding box to the geometry.
geometry PostGIS_AddBBox
geometry geomA
Description
Add bounding box to the geometry. This would make bounding
box based queries faster, but will increase the size of the
geometry.
Bounding boxes are automatically added to geometries so in general this is not needed
unless the generated bounding box somehow becomes corrupted or you have an old install that is lacking bounding boxes. Then you need to drop the old and re-add.
&curve_support;
Examples
UPDATE sometable
SET geom = PostGIS_AddBBox(geom)
WHERE PostGIS_HasBBox(geom) = false;
See Also
,
PostGIS_DropBBox
Drop the bounding box cache from the geometry.
geometry PostGIS_DropBBox
geometry geomA
Description
Drop the bounding box cache from the geometry. This reduces
geometry size, but makes bounding-box based queries slower. It is also used to drop a corrupt bounding box. A tale-tell sign of a corrupt cached bounding box
is when your ST_Intersects and other relation queries leave out geometries that rightfully should return true.
Bounding boxes are automatically added to geometries and improve speed of queries so in general this is not needed
unless the generated bounding box somehow becomes corrupted or you have an old install that is lacking bounding boxes.
Then you need to drop the old and re-add. This kind of corruption has been observed in 8.3-8.3.6 series whereby cached bboxes were not always recalculated when a geometry changed and upgrading to a newer version without a dump reload will not
correct already corrupted boxes. So one can manually correct using below and re-add the bbox or do a dump reload.
&curve_support;
Examples
This example drops cached bounding boxes where the stored box is wrong. Applying Box2D to ST_AsBinary forces a fresh box calculation, while Box2D on the table geometry reads the cached box.
UPDATE sometable
SET geom = PostGIS_DropBBox(geom)
WHERE Not (Box2D(ST_AsBinary(geom)) = Box2D(geom));
UPDATE ...
After dropping corrupt cached boxes, re-add them where needed.
UPDATE sometable
SET geom = PostGIS_AddBBox(geom)
WHERE Not PostGIS_HasBBOX(geom);
UPDATE ...
See Also
, ,
PostGIS_HasBBox
Returns TRUE if the bbox of this geometry is cached, FALSE otherwise.
boolean PostGIS_HasBBox
geometry geomA
Description
Returns TRUE if the bbox of this geometry is cached, FALSE
otherwise. Use and to control caching.
&curve_support;
Examples
SELECT geom
FROM sometable WHERE PostGIS_HasBBox(geom) = false;
See Also
,