Move Over To PostgreSQL With Babelfish and MangoDB
Written by Nikos Vaggalis   
Tuesday, 16 November 2021

Babelfish and MangoDB are two solutions that move your application workloads from SQL Server and MonoDB respectively to PostgreSQL.

We have repeatedly outlined why PostgreSQL rules the DBMS world. Some examples are PostgreSQL 14 Is Here - A Look At Its Past And Future and PostgreSQL Is DB-Engines DBMS of the Year For 2020.

While there are existing methods for moving from DBMS "A" to Postgres, as The Complete Oracle to PostgreSQL Migration Guide by EDB demonstrates, migrating application code is a whole different concept.To meet this need Babelfish and MangoDB let PostgreSQL understand queries from applications written for Microsoft SQL Server and MongoDB respectively.


Babelfish is a set of extensions that provide both T-SQL capabilities and a Tabular Data Stream (TDS) listener port as enhancements to PostgreSQL. It supports the SQL Server dialect, T-SQL, and notable features including savepoints, stored procedures, nested transactions, etch.

while MangoDB

is a stateless proxy, which converts MongoDB protocol queries to SQL, using PostgreSQL as a database engine. It is compatible with MongoDB drivers, and should work as a drop-in replacement to MongoDB in many cases.

So what are their benefits?

To start with, getting rid of licensing fees, since you move from propriety SQL Server to open source PostgreSQL. But what about MongoDB, isn't it open source already? Yes, but it has recently changed its license to SSPL (check The SSPL is Not an Open Source License) making it unusable for many Open Source and Commercial Projects.

With this approach you can port your application originally built for SQL Server and MangoDB to work with a Postgres backend engine. For instance, Babelfish has its own parser that creates the appropriate query nodes, so that the SQL Server dialect can be executed by PostgreSQL natively. Babelfish also supports T-SQL semantics, plus it uses the same network protocol, port, and connectivity drivers of SQL Server which by default runs on port 1433.

Babelfish comes as a patch against community PostgreSQL, and a bunch of extensions built on top of the patch: 

  • babelfishpg_tsql: supports the T-SQL language
  • babelfishpg_tds: supports the TDS wire protocol
  • babelfishpg_common: supports new datatypes found in T-SQL
  • babelfishpg_money: supports the money type in SQL Server

As for MangoDB, it acts as an open-source proxy which converts MongoDB wire protocol queries to SQL, and uses PostgreSQL as the database engine, hence acting as a drop-in replacement for MongoDB in many cases. This way, MongoDB drivers and even tools can be used with an application which would otherwise rely on MongoDB, while still benefiting from the ease and flexibility of a document database, especially given Postgres' strong JSON capabilities.

As already said, both Babelfish and MangoDB are Open Source software under the terms of the Apache 2. 0 license. As such both projects are hosted on Github as well.


More Information

Goodbye Microsoft SQL Server, Hello Babelfish

MangoDB-A truly Open Source MongoDB alternative

BabelFish on GitHub

MangoDB on GitHub

Related Articles

PostgreSQL 14 Is Here - A Look At Its Past And Future 

PostgreSQL Is DB-Engines DBMS of the Year For 2020

SQL Server on Linux, Love or Calculated Move?


To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.


Avi Wigderson Gains Turing Award

Israeli mathematician and computer scientist, Avi Wigderson, is the recipient of the 2023 ACM A.M Turing Award which carries a $1 million prize with financial support from Google.

The Experience AI Challenge

The Raspberry Pi Foundation in collaboration with Google DeepMind has announced the Experience AI Challenge. Its intention is to guide young people under the age of 18, and their mentors, through [ ... ]

More News

raspberry pi books



or email your comment to:

Last Updated ( Tuesday, 16 November 2021 )