How Devs Can Use Postgres Extensions, Including for AI Apps
PostgreSQL (typically called Postgres) is a popular free and open source relational database. It’s attracted a lot of extensions and third-party tools over the years, which has inspired a company called Tembo to build a “Postgres as a Platform” service — a kind of marketplace for Postgres extensions and other tools. The goal is to enable devs to “build any application on Postgres.”
To find out more, I spoke to its CTO Samay Sharma, who previously worked at Microsoft managing a team of Postgres committers and contributors.
Tembo is promoting itself as “the managed cloud to run Postgres and its entire ecosystem — extensions, applications, tools, and more — all within a single unified platform.” But it is extensions in particular that Sharma wanted to emphasize.
“It’s, in my opinion, the time for extensions to take center stage and to drive transformative applications built on top of Postgres,” he told me. He added that “database sprawl” is an increasing problem for developers — where there are multiple databases within an organization, and not all of them are compatible. Sharma thinks “most of these problems could be just solved by Postgres with a couple of extensions.”
Application-Specific Postgres, Including for AI Apps
There is certainly no shortage of managed service providers for Postgres, which Sharma acknowledged. But what Tembo aims to do is provide an “application-specific Postgres” where extensions are a big part of the service.
“We also tune Postgres differently based on your application needs, on your workloads, so on and so forth,” he continued. The goal is to help application developers who aren’t database experts to get the most out of Postgres.
Given that we’re in the age of generative AI, which has its own data requirements — such as using vector databases to optimize content before and after it gets processed by an LLM — I asked how Tembo is addressing the AI trend.
“Postgres has an extension called pgvector,” he explained. “So that allows you to add a simple data type called vector to your existing tables. So even if you have your existing row of data, you could just add a vector data type — which is a transformed embedding.”
He added that at Tembo, they have built an extension called pg_vectorize, which he said “allows you to fetch OpenAI embeddings from within Postgres.”
Previously extensions could only be written in C, he noted, but now they can be written in Rust as well. The extension takes a Postgres column “and then queries OpenAI, generates the embeddings, and stores that right next to your database, with just one function call.”
In addition to pg_vectorize, Tembo has over 200 other extensions on offer. Extensions that are popular with its users include geospatial, data warehousing, and “approximate aggregation algorithms.” On the data warehousing side, Sharma noted that one of the attractions of using Postgres extensions is that it’s a cost-effective alternative to using a solution from a large provider (he mentioned Snowflake as an example).
“Historically, developers with very small amounts of data have had to go to expensive technologies […] way beyond what their current needs are,” he said.
Sharma says that Tembo’s goal is to “collapse the data stack,” so that “you can use one platform to get any flavor of database you need, as opposed to going to 15 vendors, buying 15 different databases, and then learning how to piece them together.”
Using AI to Generate SQL
I mentioned that some developers I know are using a large language model or Copilot product to translate from whatever programming language they’re using into SQL, or vice versa. Or, as Jon Udell recently demonstrated here on The New Stack, using AI to improve their SQL queries. I asked if Tembo has that kind of functionality.
He confirmed that there are Postgres extensions that transform natural language queries into SQL queries — pg_human is one example. He added that several years into the future, you might be able to just talk to your data directly, using natural language.
“The actual behavior you want at the end of the day is [that] there’s all your data consolidated in a single platform, and you’re able to ask it the questions you want to ask it,” he said. “Now, today, you use SQL as a way to do that — but over time, with the new kinds of SQL generation capabilities from natural language [processing], I think it’s possible that we will get to this point.”
Why Now for an Extensions Marketplace?
To conclude, Sharma said that Tembo’s goal is to create “a marketplace of extension” for Postgres. He acknowledged that Postgres extensions have been around for a while, but he thinks this is the right time to build a marketplace because there are more and more developers of extensions, but their products aren’t being utilized enough.
“Finding documentation for extensions is hard, finding extensions themselves is hard, judging their maturity is hard,” he said. “So it’s important for a vendor to kind of take that responsibility, in terms of maturing the ecosystem.” Tembo, it seems, wants to be the default vendor for Postgres extensions.