Babelfish for ApsaraDB RDS for PostgreSQL

更新时间:
复制 MD 格式

Babelfish lets your ApsaraDB RDS for PostgreSQL instance understand T-SQL statements and accept TDS connections, so you can run SQL Server workloads on PostgreSQL with minimal code changes.

What is Babelfish

Babelfish for ApsaraDB RDS for PostgreSQL is based on the open source Babelfish for PostgreSQL project. Enable Babelfish when you create an RDS PostgreSQL instance to parse and execute SQL Server T-SQL statements alongside native PostgreSQL queries.

Babelfish supports the SQL Server Tabular Data Stream (TDS) wire protocol and T-SQL, the Microsoft SQL Server query language. You can migrate SQL Server applications to RDS PostgreSQL with minor code changes, without switching database drivers or rewriting SQL statements.

T-SQL built-in functions supported by Babelfish

Scenarios

  • Reduce SQL Server license costs.

  • Migrate from SQL Server to PostgreSQL with minimal application changes.

  • Access PostgreSQL extensions such as PostGIS for spatial analysis and TimescaleDB for time series data.

  • Get dual-engine capabilities (SQL Server and PostgreSQL) at single-instance cost.

Architecture

image

How Babelfish processes SQL requests:

  • The instance listens on two TCP ports for SQL requests:

    • TDS Listener: Receives SQL requests on the TDS port. Default port: 1433.

      Note

      Babelfish supports TDS protocol 7.1 and later (SQL Server 2000+).

    • PostgreSQL Listener: Receives SQL requests on the PostgreSQL port. Default port: 5432.

      Note

      ApsaraDB RDS for PostgreSQL 15 is currently supported.

  • Requests from the TDS port go to the T-SQL parser, which converts T-SQL into a PostgreSQL execution plan.

  • Requests from the PostgreSQL port go through the native PostgreSQL parser.

  • The PostgreSQL executor processes all execution plans.

With Babelfish, a single RDS PostgreSQL instance serves both SQL Server and PostgreSQL clients, reducing costs while expanding capabilities.

Migration modes

Babelfish stores all migrated SQL Server objects and structures in a PostgreSQL database named babelfish_db.

Note

If you connect to the instance through the TDS port, the babelfish_db database is not visible.

Choose Single-DB or Multi-DB mode. Your choice affects the schema and name of the SQL Server database within babelfish_db.

Single-DB mode

  • Architecture: single-db

  • Description: Schema names in babelfish_db match the original SQL Server schema names directly.

    Example: You create database DB_A over the TDS port with schema schema_A.

    • In the babelfish_db database of PostgreSQL, the schema names are dbo and schema_A.

    • In the DB_A database of SQL Server, the schema names are dbo and schema_A.

Multi-DB mode

  • Architecture: Multi-DB

  • Description: PostgreSQL schemas use the format dbname_schemaname. SQL Server schema names remain unchanged.

    Example: You create database DB_A over the TDS port with schema schema_A.

    • In the babelfish_db database of PostgreSQL, the schema names are DB_A_dbo and DB_A_schema_A.

    • In the DB_A database of SQL Server, the schema names are dbo and schema_A.

Billing

Babelfish adds no extra cost to your RDS PostgreSQL instance. Pricing depends on region, specifications, and storage, as listed on the ApsaraDB RDS purchase page.

Usage notes

  • You cannot enable Babelfish for an existing ApsaraDB RDS for PostgreSQL instance.

  • After you enable Babelfish, you cannot disable it.

  • After the instance is created, a database named babelfish_db is initialized. This database is critical to the Babelfish feature. Do not delete it, or the instance will become unavailable.

Get started