Everyone Uses Postgres...But Why?
All big players in the market use PostgreSQL nowadays. But why is that? Find out the answer in this article.
Join the DZone community and get the full member experience.
Join For FreeAll big players in the market use PostgreSQL nowadays. Postgres is just the best and the most popular solution these days, no matter if it’s for startups or enterprise companies. But why is that? What makes PostgreSQL so great and why did companies abandon their enterprise-ready databases like Oracle, MS SQL, or DB2? Read on to find the answers.
The world has changed significantly in the last few years. We work with cloud-native applications and microservices, and we rarely deploy monolithic ecosystems. Due to that, many companies (both start-ups and Fortune 500 enterprises) switch from their typical enterprise-ready databases (like Oracle, MS SQL, or IBM DB2) to PostgreSQL. This trend is visible globally and may come as a surprise to some people.
In this blog post, we will address a couple of points. First, we analyze if PostgreSQL is indeed the most popular database according to companies and developers. Next, we’ll explore why it is being used by big companies. Finally, we are going to check if it is enterprise-ready and explain what makes it better than other SQL databases.
Who Uses Postgres?
Before explaining why PostgreSQL is everywhere, let us first check if that’s the case. We know that many companies promote the things they use and tend to focus only on the good sides, but the reality (especially on the enterprise level) quickly verifies these products. Enterprises may easily outscale them and show that they can’t be trusted in demanding environments.
Companies Using Postgres
Let’s explore some of the big companies that use PostgreSQL in their day-to-day operations. We won’t be going much into how they use it and we’ll just link to their materials. Feel free to explore more on their technical blogs and design documents.
- Instagram handles millions of photos every day. According to Statista, Instagram has two billion monthly active users as of early 2024. They keep their user data, friendships, media, and others in PostgreSQL, as shown in their tech blog.
- Reddit has over half a billion accounts as of 2024. To support that, they use PostgreSQL as a ThingDB (sort of key-value store) and as a regular SQL database. See more in their write-up.
- Skype, with over 300 million monthly active users, uses PostgreSQL for things like batch jobs or queueing. See their presentation.
- Spotify, with more than 600 million users each month, uses PostgreSQL for various storage needs.
- Robinhood, with more than 10 million users, uses PostgreSQL in its data lake.
- Twitch has most of its 125 OLTP databases running PostgreSQL.
- NASA and its International Space Station use PostgreSQL.
We can see many big companies use PostgreSQL in their production systems. Saying that PostgreSQL is everywhere is not an overstatement. It is indeed powering both OLTP and OLAP workloads, with millions of users and transactions every day.
Developers and Their Preferences
Similarly, developers’ sentiment makes PostgreSQL the most popular database in the world. According to Stack Overflow Developer Survey 2023, PostgreSQL leads the way among professional developers and the overall population:
Since developers like Postgres so much, they will encourage their teams and management to use it more. Therefore, we can expect PostgreSQL to grow even more popular in the upcoming years.
Postgres Contributors
Companies both use and develop PostgreSQL. According to the EDB diagram, AWS, Microsoft, and VMware significantly support the development of PostgreSQL.
This shows that PostgreSQL is not a toy but gets strong support from the market and the whole industry.
I Like My Oracle and DB2: Why Would I Switch?
Let’s now consider why would we even switch to PostgreSQL from other enterprise-ready databases like Oracle, DB2, or Microsoft SQL Server. It is a valid question as PostgreSQL doesn’t have an enormous owner like other databases do and we might suspect that it’s behind other products. Let’s see if that’s the case.
PostgreSQL Has Strong Foundations
It may come as a surprise that PostgreSQL was actually one of the first Relational Database Management Systems in the world. In 1973, Michael Stonebraker from the University of California Berkeley decided to develop an implementation of the relational model suggested by Edgar F. Codd. It was first named Ingres and was implemented just to demonstrate that the relational model is viable and can compete with other database models of the era (mostly CODASYL and hierarchical).
The project didn’t stop after that. In 1980, Stonebraker co-founded Relational Technology, Inc. to produce a commercial version of Ingres. This is how Postgres emerged. The database was used mostly for research and experimentation until Stonebraker co-founded Illustra Information Technologies in 1992 to create a database for all companies around the world.
Finally, Postgres dropped QUEL language and switched to SQL in 1994, and was renamed to Postgres95 and PostgreSQL eventually.
Can PostgreSQL Replace My Existing Databases?
Postgres supports the essential features needed in the enterprise world. Let’s see some of them.
- Indexes: Postgres supports many types of indexes, including B-Tree, GIN, GiST, BRIN, vector, and others. Postgres can rebuild indexes online.
- Security: Postgres supports both the privilege system and row-level security policies.
- Replication and high availability: Postgres supports primary servers and standby replicas. It supports both streaming replication and logical replication. It supports log-shipping, streaming, and other solutions for continuous archiving.
- Columnar storage: PostgreSQL supports columnar storage thanks to many extensions, like Hydra or ParadeDB.
- Isolation levels: PostgreSQL supports both true serializable isolation levels and snapshots.
- Failover and load Balancing: Postgres supports failover and load balancing.
- Partitioning: PostgreSQL supports table partitioning with various policies.
- Encryption: Postgres supports encryption on various levels, including column encryption, data partition encryption, or client-side encryption.
- OLAP: Postgres can deal with OLTP and OLAP workloads.
- Cloud deployment: PostgreSQL can be deployed in the cloud with AWS RDS, Amazon Aurora, Azure Database for PostgreSQL, or Cloud SQL for PostgreSQL.
- Vendor lock-in: Postgres can be deployed on-premise or with other infrastructure providers like Tembo.
As we can see, PostgreSQL supports everything that is needed for enterprise-ready database systems. However, there is more. Postgres supports many unique things that make it even better when compared to competitors. Let’s read on to see what.
Things That Make PostgreSQL Better
PostgreSQL is an open-source database. Therefore, anyone can extend it to provide more features. This makes it highly configurable. For instance, AWS extends PostgreSQL with postgresql-logfdw to let users easily read database logs stored in CloudWatch.
Postgres can be easily adapted to build highly tailored solutions. For instance, Amazon Redshift can be considered a highly scalable fork of Postgres. It’s a distributed database focusing on OLAP workloads that you can deploy in AWS.
Postgres make it easy to adopt new technologies and they can be put inside the database with little-to-no hassle. For example, you can run DuckDB directly inside Postgres thanks to pg_analytics.
However, the biggest power of PostgreSQL is its extensions. Postgres has a very extensible extension mechanism that people use to build much more than just SQL features. Let’s see what else can be done with Postgres.
Postgres Is Much More Than SQL
PostgreSQL is not only an SQL database anymore. Thanks to its powerful extensions, it supports many other workloads and scenarios. Let’s see some of them. We cover them in detail in our other article about PostgreSQL Everywhere.
PostgreSQL is capable of storing different types of data. In addition to standard numbers and text, you might need to store more complex data such as nested structures, spatial information, or mathematical formulas. Querying this kind of data can be much slower without the use of specialized data structures that are optimized to comprehend the content of the columns. Thankfully, PostgreSQL offers various extensions and technologies designed to handle non-relational data efficiently. It can deal with XML, JSON, spatial data, intervals, vectors, and much more.
Full-text search (FTS) is a technique that involves analyzing every word in a document to find matches with the query. Instead of just locating documents containing the exact phrase, it also identifies similar phrases, accounts for typos, patterns, wildcards, synonyms, and more. This process is more challenging because each query is more complex, increasing the chance of false positives. Additionally, instead of directly scanning each document, the data set needs to be transformed to precompute aggregates, which are then utilized during the search process. PostgreSQL supports FTS with various extensions and can easily outperform Elasticsearch in many production scenarios.
For analytical purposes, data is often gathered from various sources, such as SQL and NoSQL databases, e-commerce platforms, data warehouses, blob storage, log files, and clickstreams, among others. This data is typically collected during the ETL process, which involves loading information from different locations. PostgreSQL natively supports this through Foreign Data Wrappers. PostgreSQL can read data from S3, Azure, AWS, data lakes, and other databases. We can easily build a data lake with Postgres.
Postgres supports many data storage formats. It can deal with regular tables, columnar storage, parquet files, time series, and much more. This way, we can improve analytical queries and turn Postgres into OLAP or even HTAP solutions.
Postgres provides incrementally updated materialized views that are perfect for time series data. We can define aggregates that are constantly recalculated and kept up-to-date even when we modify the data.
Postgres can serve as a vector database for AI-based solutions. With the rise of ChatGPT and other large language models, we want to empower our solutions with Retrieval-Augmented Generation. This can be easily implemented with PostgreSQL support for vector operations.
Long story short, Postgres can deal with anything. It’s not just an SQL database for OLTP workloads. It can support any modern workload required in cloud-native distributed computing.
The Future Is Now and Postgres Is Ready
With its extensions mechanism, Postgres can support any type of workload. This makes it a very interesting platform for building solutions for new domains. Instead of building a new database from scratch, we can just extend PostgreSQL with the new capabilities and let it deal with the hard part of optimization, security, user management, and other elements that every production-grade system must have.
No matter whether we are talking about custom data types, another in-memory process, or AI use cases, Postgres can be tuned to support new scenarios. When some new requirement comes into play, we don’t need to start from scratch but we just need to extend PostgreSQL with an extension. Postgres is ready for whatever the future brings.
Enterprises Don’t Ignore Postgres and Nor Should You
PostgreSQL is widely recognized as one of the most popular SQL databases, but it offers far more than just an SQL engine. With a variety of extensions, PostgreSQL can now manage non-relational data, full-text searches, analytical processes, time series, and more. The distinction between OLAP and OLTP is no longer necessary, as PostgreSQL enables the execution of HTAP workflows within a single database. PostgreSQL supports enterprise-level requirements around HA, scalability, permissions, or security. This versatility makes PostgreSQL an exceptionally adaptable database capable of meeting a wide range of requirements and explains why it’s now the most popular database in the world.
Published at DZone with permission of Adam Furmanek. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments