(In)efficient Insertions in Postgres

submited by
Style Pass
2024-10-01 01:00:06

PostgreSQL is a popular relational database that is used for variety of applications. With the recent surge in popularity of Generative AI (Large Language Models in particular), PostgreSQL is often used for storing document “embeddings” (low-level representation of documents) to enhance search functionality. In addition to the ability to “search” similar documents in a query, it is used primarily due to its reliability, speed, and community support (I know, some folks might say relational databases are slow, but there are plenty of ways to tune the database to all kinds of use cases and access patterns).

The SQL in PostgreSQL is already a spoiler for what language is used to retrieve or store the data. One of the common ways, which is also part of SQL standard, is to use INSERT command:

In the example below, we insert (store) a single row containing 3 columns. This classic usage of INSERT is quite common when you need to store a few rows (e.g. when you need to insert new information in real time).

Leave a Comment