Class ExtentEstimator
java.lang.Object
org.apache.sis.internal.sql.postgis.ExtentEstimator
Estimation of the extent of geometries in a given table or column using statistics if available.
Uses the PostGIS
ST_EstimatedExtent(…)
function to get a rough estimation of column extent.
If ST_EstimatedExtent(…)
gave no result and it was the first attempt on the specified table,
then this class executes ANALYZE
and tries again to get the extent. This strategy works well
when requesting envelope on newly created tables.
Design notes
We do not use the most accurateST_Extent
function because it is costly on large tables.
At the time of writing this class (December 2021), ST_Extent
does not use column index.- Since:
- 1.2
- Version:
- 1.2
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SQLBuilder
A temporary buffer with helper methods for building the SQL statement.private final Column[]
All columns in the table (including non-geometry columns).private final Database
The database containing the table for which to estimate the extent.private GeneralEnvelope
The union of all extents found, ornull
if none.private org.opengis.referencing.operation.TransformException
Errors that occurred during envelope transformations, ornull
if none.private final TableReference
The table for which to get the extent. -
Constructor Summary
ConstructorsConstructorDescriptionExtentEstimator
(Database database, TableReference table, Column[] columns) Creates a new extent estimator for the specified table. -
Method Summary
Modifier and TypeMethodDescription(package private) GeneralEnvelope
Estimates the extent in the specified columns using PostgreSQL statistics.private void
Estimates the extent in the specified columns using current statistics.
-
Field Details
-
database
The database containing the table for which to estimate the extent. -
table
The table for which to get the extent. -
columns
All columns in the table (including non-geometry columns). This is a reference to an internal array; do not modify. -
builder
A temporary buffer with helper methods for building the SQL statement. -
envelope
The union of all extents found, ornull
if none. -
error
private org.opengis.referencing.operation.TransformException errorErrors that occurred during envelope transformations, ornull
if none.
-
-
Constructor Details
-
ExtentEstimator
ExtentEstimator(Database database, TableReference table, Column[] columns) Creates a new extent estimator for the specified table.
-
-
Method Details
-
estimate
Estimates the extent in the specified columns using PostgreSQL statistics. If there are no statistics available, then this method executesANALYZE
and tries again.- Parameters:
statement
- statement to use for executing queries. Shall be closed by caller.recall
- if it is at least the second time that this method is invoked for the table.- Returns:
- an estimation of the union of extents in given columns, or
null
if unknown. - Throws:
SQLException
-
query
Estimates the extent in the specified columns using current statistics. If there are no statistics available, then this method returnsnull
.- Parameters:
statement
- statement to use for executing queries. Shall be closed by caller.- Throws:
SQLException
-