Skip to main content
2 of 5
deleted 10 characters in body
Evan Carroll
  • 64.7k
  • 49
  • 251
  • 496

This is not a very good idea, and there is no to do this. Just create a functional index.

CREATE INDEX ON table ( ROUND( (ST_Area(geom)/1000)::numeric ,2 ) );

I would create the index on the unrounded version.

CREATE INDEX ON table ( ST_Area(geom) );

Then a query like this..

SELECT * ON table WHERE ST_Area(geom) > x;

Will use the index. Alternatively, you can create a MATERIALIZED VIEW. Generally, it's not a good idea to cache the result of a calculation on the table.

Evan Carroll
  • 64.7k
  • 49
  • 251
  • 496