stac-utils / pgstac

Schema, functions and a python library for storing and accessing STAC collections and items in PostgreSQL
MIT License
153 stars 39 forks source link

Removing queryables indices #225

Open drnextgis opened 1 year ago

drnextgis commented 1 year ago

I notice that in #210, eo:cloud_cover has been excluded from the list of queryables. Is there a function available to also remove the corresponding index from all partitions, or is this a manual task? Also I'm curious about the choice to initially use the to_int property wrapper there instead of to_float. Are there any specific advantages to using it in this context?

bitner commented 1 year ago

The maintain_partitions can be used to make sure that all indexes match what is defined in the queryables table. Generally, you do not need to manually call this function as it will be called by triggers on the queryables table as well as on when running the check_partition function. When called by a trigger, the behavior will be to not remove any indexes that don't match the desired indexes as defined by queryables.

You can run by hand to remove any indexes using `SELECT maintain_partitions('items',TRUE);

BTREE indexes as of Postgres 15 (maybe it was 14, not sure off the top of my head) allow for deduplication of identical rows which means that an index on a casted floats to int can be much smaller/faster than the same index would be on a float. The smaller matters less about disk space, but more in that the entire index is more likely to stay in memory. This is, of course, at the cost of precision, but for fields where that precision may not be critical, it can be advantageous to index as ints.

zacdezgeo commented 7 months ago

@bitner, should we plan on adding anything about this to the docs? Maybe under the indexes section in docs/src/pgstac.md?