1

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:

0103000020E61000000100000005000000800F04E8AE1751C09EEE3F0181234640F04A8F5A600E51C09EEE3F0181234640F04A8F5A600E51C079B75A336B314640800F04E8AE1751C079B75A336B314640800F04E8AE1751C09EEE3F0181234640

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:

  1. How can I create a bounding box representation using the EWKB value in the bounding_box field? Aggregate functions like ST_POLOGONIZE are not allowed within WHERE blocks.
  2. Is ST_DWITHIN usage appropriate here?
  3. This function will be executed many times. What sort of optimizations are suggested?
2

It is suggested to use the bounding box operators from PostGIS:

PostGIS BBOX operators

The bounding box will be automatically derived from the geometries when you use one of the boundingbox operators, so no need to create a new bounding box geometry.

The ST_DWITHIN function as well as the bounding box operators usually exhibit a decent performance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.