Opened 3 years ago

Closed 3 years ago

#5427 closed enhancement (fixed)

PostGIS: use ST_EstimatedExtent instead of ST_Extent when possible

Reported by: gabrimonfa Owned by: warmerdam
Priority: normal Milestone: 1.11.0
Component: default Version: unspecified
Severity: normal Keywords:
Cc:

Description

In PostGIS driver function GetExtent? uses PostGIS function ST_Extent function.

When bForce is false it may be worth to attempt to use ST_EstimatedExtent that is much quicker and returns an extimated extent based on table metadata.

Some notes

  • as of now ST_Extent support more data type than ST_EstimatedExtent
  • the name has changed between PostGIS 2.0.x (ST_Estimated_Extent) and PostGIS 2.1 (ST_EstimatedExtent)
  • In case of empty table or no statistics ST_EstimatedExtent returns NULL (PostGIS version >=1.5.4) or an exception. In this case we can fallback on ST_Extent

A very rough patch, to be reworked and tested, is provided

Attachments (1)

rough_patch_ST_EstimatedExtent.diff (2.7 KB) - added by gabrimonfa 3 years ago.
Rough patch to attempt to use ST_EstimatedExtent (to be reworked)

Download all attachments as: .zip

Change History (3)

Changed 3 years ago by gabrimonfa

Rough patch to attempt to use ST_EstimatedExtent (to be reworked)

comment:1 Changed 3 years ago by gabrimonfa

Summary: PostGIS use ST_EstimatedExtentPostGIS: use ST_EstimatedExtent instead of ST_Extent when possible

comment:2 Changed 3 years ago by Even Rouault

Milestone: 1.11.0
Resolution: fixed
Status: newclosed

There were several issues in your patch. The main one being that estimated_extent syntax is "select estimated_extent('schema_name', 'table_name', 'geometry_name)'" (without any from clause).

Hopefully fixed by :

trunk r27106 "PG: use ST_Estimated_Extent() on table layers if GetExtent?() is called with force = 0 (derived from patch by gabrimonfa, #5427)"

Note: See TracTickets for help on using tickets.