We have a table in which there are millions of rows with PostGIS geometries. The query we want to fulfill is: what are the most recent records that fall into the bounding geometry? The problem with this query is that we often will have a large number of elements that match the bounding box (which has a radius of 5 km), and Postgres will then need to double-check all returned elements in the bounding box to get their timestamp, then sort and return the latest version.
It looks like we need an index (composite?) That takes into account both the spatial GIST index and the timestamp. Is it possible? I tried several combinations in the CREATE INDEX step, and so far nothing has worked.
source share