Please sign in to comment.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mssql] Use Filter instead of STIntersects to improve query performance
...and refine validity test from 57dc3c7 Using Filter is more performant since it does a bounding box only check when an appropriate spatial index is available. This matches the behavior with other providers, where the provider filter only does a bounding box check and callers must perform the actual intersection check if required. While Filter also avoids SQL server closing the iterator upon encountering invalid geometries, we can't rely on this because SQL server will transparently fall back to STIntersects if it decides there's no suitable spatial indexes available, and then throw an exception on invalid geometries. So we still require the STISValid check when using Filter. The extent calculation from 57dc3c7 has been refined to avoid the very expensive STMakeValid call. Instead we use a (ugly!) workaround to skip invalid geometries using STIsValid only inside the min/max x/y aggregates. Note that we can't just dump a WHERE STIsValid clause in to the statement because SQL server still throws the exception. Gotta love it! Fix #15752, #10947
- Loading branch information
Showing with 12 additions and 4 deletions.