[postgis-users] Is it possible to do constraint exclusion based on spatial extents?

Stephen Woodbridge woodbri at swoodbridge.com
Sun Aug 2 12:04:31 PDT 2015


Hi,

I know I can setup table inheritance and constraint exclusion based on 
say the state field. But I would like to do this based on geom and the 
table extents. How would I do this?

Say for example, I create a roads table, then load data into 
roads_area1, roads_area2, etc and these inherit from roads.

For the state abbrv. I might have:

ALTER TABLE roads_area1 ADD CONSTRAINT chk
    CHECK (state IN ('MA', 'ME', 'NH'));

So doing the same based on geom column might look like:

ALTER TABLE roads_area1 ADD CONSTRAINT bbox_chk
CHECK (geom && <????>);

So does this work?

Do I need to do anything special to get postgresql to using constraint 
exclusion? What?

How would I set <????>?

These tables are create once and query often, so the extents are not 
changing after they are loaded.

Thanks,
   -Steve W


More information about the postgis-users mailing list