I'm trying to implement some search functionality for a web app, and have run into an issue where I don't know the proper functions to execute this.
Given a Point, a
bounding_box database field with the EWKB representation of the geometry and a given distance value (aka 10km), I want to find all records that are within the radius or intersect with the outer boundary.
An example bounding box is:
Given that this function will be executed many times, with possible caching, I'd like to avoid any ST_BUFFER usage.
There are multiple things happening here:
- How can I create a bounding box representation using the EWKB value in the
bounding_boxfield? Aggregate functions like ST_POLOGONIZE are not allowed within WHERE blocks.
- Is ST_DWITHIN usage appropriate here?
- This function will be executed many times. What sort of optimizations are suggested?