You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

EdgeDB新手技术咨询:能否直接在EdgeDB中使用PostGIS等Postgres扩展?

Using PostGIS with EdgeDB: What You Need to Know

Hey there! As someone who’s worked with both EdgeDB and PostGIS, I get where you’re coming from—making the switch to a new database while relying on existing spatial tooling can feel tricky. Let’s break down your question clearly:

Short Answer

EdgeDB doesn’t support direct use of Postgres extensions like PostGIS right out of the box. It’s built on top of Postgres but has its own abstracted layer that doesn’t expose Postgres’s native extension system directly. But don’t worry—there are solid workarounds to keep using your PostGIS workflows while adopting EdgeDB.

Workarounds & Next Steps

1. Leverage EdgeDB’s Built-In Spatial Features (In Progress)

You mentioned GIS is on EdgeDB’s roadmap, and they’ve already rolled out basic spatial support that might cover your core needs. Right now, you can use types like std::geo::Point, std::geo::Polygon, and std::geo::LineString, plus functions for common operations like:

  • Calculating distances between points
  • Checking if shapes intersect
  • Validating spatial objects

Keep an eye on EdgeDB’s release notes—they’re expanding this support rapidly, and future versions will add more PostGIS-compatible features.

2. Hybrid Architecture: EdgeDB + Postgres via Foreign Data Wrappers

If you need PostGIS’s advanced features (like raster processing, complex geospatial queries, or specialized functions), a hybrid setup works great:

  • Keep your spatial data in a Postgres instance with PostGIS enabled
  • Use EdgeDB’s pgfs (PostgreSQL Foreign Data Wrapper) extension to connect to that Postgres database. This lets you query PostGIS tables directly from EdgeDB, and even map them as "foreign objects" in your EdgeDB schema.

Here’s a quick example of how to set this up:
First, enable the pgfs extension in EdgeDB:

CREATE EXTENSION pgfs;

Then create a foreign data source pointing to your PostGIS-enabled Postgres DB:

CREATE FOREIGN DATA SOURCE postgis_db
  TYPE pgfs
  OPTIONS (
    host 'localhost',
    port '5432',
    dbname 'your_postgis_database',
    user 'postgres',
    password 'your_db_password'
  );

Map a PostGIS table to an EdgeDB foreign table:

CREATE FOREIGN TABLE postgis_locations (
  id UUID,
  geom std::geo::Polygon,
  location_name str
)
  FROM postgis_db "public.locations";

Now you can query this table just like any other EdgeDB table, and even join it with your EdgeDB-native data.

3. Wrap PostGIS Functions in EdgeDB Custom Functions

If you need to call specific PostGIS functions directly from EdgeDB, you can create custom EdgeDB functions that proxy to PostGIS. For example:

CREATE FUNCTION st_buffer(geom std::geo::Polygon, distance float64) -> std::geo::Polygon
  USING LINK postgis_db
  AS $$SELECT ST_Buffer($1::geometry, $2)::geometry$$;

This lets you call st_buffer() right in your EdgeDB queries, with the heavy lifting handled by PostGIS in your linked Postgres instance.

4. Wait for Full EdgeDB GIS Support

EdgeDB’s team is actively working on expanding spatial capabilities to match (and even exceed) PostGIS. If your project can afford to wait, future releases will likely eliminate the need to rely on Postgres for spatial operations entirely.

Final Thought

While you can’t drop PostGIS directly into EdgeDB today, the hybrid approach lets you keep using your existing spatial infrastructure while you transition to EdgeDB’s powerful data modeling features. Start small—test EdgeDB’s built-in spatial tools for simple tasks, and use the foreign data wrapper for PostGIS-specific work.

内容的提问来源于stack exchange,提问作者omid

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.27 19:12:43