ST_EstimatedExtent

Name

ST_EstimatedExtent — Returns the estimated extent of a spatial table.

Synopsis

box2d ST_EstimatedExtent ( text schema_name , text table_name , text geocolumn_name , boolean parent_only ) ;

box2d ST_EstimatedExtent ( text schema_name , text table_name , text geocolumn_name ) ;

box2d ST_EstimatedExtent ( text table_name , text geocolumn_name ) ;

Description

Returns the estimated extent of a spatial table as a box2d . The current schema is used if not specified. The estimated extent is taken from the geometry column's statistics. This is usually much faster than computing the exact extent of the table using ST_Extent or ST_3DExtent .

The default behavior is to also use statistics collected from child tables (tables with INHERITS) if available. If parent_only is set to TRUE, only statistics for the given table are used and child tables are ignored.

For PostgreSQL >= 8.0.0 statistics are gathered by VACUUM ANALYZE and the result extent will be about 95% of the actual one. For PostgreSQL < 8.0.0 statistics are gathered by running update_geometry_stats() and the result extent is exact.

[Note]

In the absence of statistics (empty table or no ANALYZE called) this function returns NULL. Prior to version 1.5.4 an exception was thrown instead.

Availability: 1.0.0

Changed: 2.1.0. Up to 2.0.x this was called ST_Estimated_Extent.

This method supports Circular Strings and Curves

Examples

SELECT ST_EstimatedExtent('ny', 'edges', 'geom');
--result--
BOX(-8877653 4912316,-8010225.5 5589284)

SELECT ST_EstimatedExtent('feature_poly', 'geom');
--result--
BOX(-124.659652709961 24.6830825805664,-67.7798080444336 49.0012092590332)