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

babelfish-for-postgresql / babelfish_extensions / 28008163716
78%
BABEL_6_X_DEV: 78%

Build:
Build:
LAST BUILD BRANCH: BABEL_5_X_DEV
DEFAULT BRANCH: BABEL_6_X_DEV
Ran 23 Jun 2026 07:23AM UTC
Jobs 1
Files 127
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 06:55AM UTC coverage: 77.549% (+0.2%) from 77.333%
28008163716

push

github

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

#### What
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.

#### Why

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%)

94 existing lines in 1 file now uncovered.

55660 of 71774 relevant lines covered (77.55%)

390542.91 hits per line

Uncovered Changes

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

Coverage Regressions

Lines Coverage ∆ File
94
95.87
0.5% contrib/babelfishpg_common/src/spatialtypes.c
Jobs
ID Job ID Ran Files Coverage
1 28008163716.1 23 Jun 2026 07:23AM UTC 127
77.55
GitHub Action Run
Source Files on build 28008163716
  • Tree
  • List 127
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #28008163716
  • bbc9edee on github
  • Prev Build on BABEL_5_X_DEV (#27958944503)
  • Next Build on BABEL_5_X_DEV (#28008522841)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc