• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

babelfish-for-postgresql / babelfish_extensions / 28022766750
77%

Build:
DEFAULT BRANCH: BABEL_6_X_DEV
Ran 23 Jun 2026 12:06PM UTC
Jobs 1
Files 128
Run time 2min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

23 Jun 2026 11:26AM UTC coverage: 77.314% (+0.2%) from 77.098%
28022766750

push

github

web-flow
Performance optimization for spatial (geometry/geography) functions  (#4874)

Currently, Babelfish's spatial type wrappers (`STIntersects`, `STContains`, `STEquals`, `STDisjoint`, `STDistance`, `STArea`, `STNumPoints`, `STDimension`,`STIsClosed`, `MakeValid`, `STGeometryType`, `HasZ`, `HasM`, `Z`, `M`, the `=`/`<>` operators, `Parse`, `Point`, `STGeomFromText`, `STPointFromText`, `STLineFromText`,`STPolyFromText`, `STMPointFromText`, `STMPointFromWKB`, `STAsText`, and bpchar/varchar/binary/varbinary cast paths) are implemented as PL/pgSQL wrappers around PostGIS C functions. Each call pays the cost of PL/pgSQL interpretation, multiple deserializations, and full GEOS topology checks even when the answer is trivially derivable from the geometry header.

With this change, all 64 spatial wrappers are reimplemented in C with header-only fast paths, point-trivially-valid short-circuits, cached-bbox short-circuits for binary predicates, and a typecode→T-SQL-name lookup table for `STGeometryType`.  T-SQL semantics — including the `"The geometry/geography instance is not valid"` error contract and `NULL`-on-mismatched-SRID for `=` — are preserved and now have explicit JDBC regression tests.

Spatial workloads on Babelfish were measurably slower than raw PostGIS due to per-row PL/pgSQL overhead. Profiling showed:
- `HasZ` / `HasM` / `STIsClosed` were ~30× slower than necessary (full deserialize for what is effectively a header-bit read).
- Constructors and `STAsText` were paying PL/pgSQL `SELECT` overhead per row.
- Validity checks ran on every row even for inputs (Points) that are valid by construction.

This PR closes those gaps without changing observable behavior or breaking the  T-SQL contract.

Task: BABEL-6444
Signed-off-by: Gopal Verma <gopalgv@amazon.com>

775 of 801 new or added lines in 1 file covered. (96.75%)

2 existing lines in 1 file now uncovered.

55749 of 72107 relevant lines covered (77.31%)

595828.65 hits per line

Uncovered Changes

Lines Coverage ∆ File
26
95.87
0.5% contrib/babelfishpg_common/src/spatialtypes.c

Coverage Regressions

Lines Coverage ∆ File
2
79.44
-0.2% contrib/babelfishpg_tds/src/backend/tds/tdsutils.c
Jobs
ID Job ID Ran Files Coverage
1 28022766750.1 23 Jun 2026 12:06PM UTC 128
77.31
GitHub Action Run
Source Files on build 28022766750
  • Tree
  • List 128
  • Changed 2
  • Source Changed 1
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #28022766750
  • 9618038e on github
  • Prev Build on BABEL_6_X_DEV (#28007996163)
  • Next Build on BABEL_6_X_DEV (#28077089988)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc