{"id":4080,"date":"2026-07-10T16:01:49","date_gmt":"2026-07-10T15:01:49","guid":{"rendered":"https:\/\/upcloud.com\/global\/?p=4080"},"modified":"2026-07-10T16:01:49","modified_gmt":"2026-07-10T15:01:49","slug":"ai-search-postgresql-database-pgvector-extension","status":"publish","type":"post","link":"https:\/\/upcloud.com\/global\/blog\/ai-search-postgresql-database-pgvector-extension\/","title":{"rendered":"Bring AI search to your PostgreSQL database with pgvector extension"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Artificial Intelligence (AI) is changing our world today. It introduced new requirements for our applications, one of which is the use of a vector database. What is a vector database? Why should we consider this for AI workloads? How does pgvector fit the engineering landscape? We will answer these questions in this article.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Without further ado, let\u2019s start digging deeper into the fascinating world of AI.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is a vector database?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A vector database is designed to index, search, and, of course, store vectors (also called embeddings). Vectors are numerical representations of data generated by AI models.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This means that databases do not store numbers or characters in a conventional way. Instead, information is converted to vectors. Any information, like documents, images, videos, or audio.<br>Similar meanings will create similar vectors.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s see an example. The sentence \u201cI love pizza\u201d will be translated into vectors and will look similar to:<br><strong>[-0.90, 0.12, 0.33]<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Another sentence, like \u201cI like burgers\u201d, will end as relatively similar vectors. But the sentence \u201cI like spaceflights\u201d will generate greater differences, as the meaning differs. So, this means really that the same word can be a different vector in the database. If we have two uses of the word \u201ccloud\u201d, like:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u201cThere are a lot of clouds in the sky today\u201d<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u201cI migrated my workloads to the cloud\u201d<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We use the same word \u201ccloud\u201d, but the meanings of those words are different. Therefore, the vectors will be different.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why do we use vectors (embeddings), not text?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Traditional database searches work by matching strings (to simplify this for the purposes of this article). Embeddings can be searched by semantic meaning, which is important for AI tools like RAG.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To explain it simply, when a user asks \u201ctell me, how to deploy kubernetes cluster?\u201d, semantic meaning search through RAG is able to capture the document named \u201cK8S deployment guide\u201d. If we compare strings, almost nothing matches. But in the vector world, the semantic meaning is very close.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is PostgreSQL?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">PostgreSQL is one of the world\u2019s most popular relational database management systems (RDBMS). It is an open-source project known for reliability, performance, scalability, and a rich ecosystem of features and plugins.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It also has some specific downsides, such as strict limits on the number of possible database connections, which leads to the use of proxy tools (connection poolers) like PGBouncer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But PostgreSQL is a relational database! And we already know that relational databases are not good for vectors! That is why we need pgvector.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is pgvector?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Pgvetor is a PostgreSQL plugin or extension that adds support for storing and querying vector embeddings directly within a database. It doesn\u2019t mean that pgvector changes PostgreSQL into a vector database. It extends a database with vector storage and capabilities, similar to those of vector databases, allowing vector workloads to coexist with relational workloads within the same database.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What does it mean for me?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This approach has several benefits<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Your team doesn\u2019t need to learn completely new technology. The database is still good old PostgreSQL. It just has one extension installed. No new DBA skills are needed to start and to expand your applications with AI tooling.<\/li>\n\n\n\n<li>Cost change stays at an acceptable level. You don\u2019t need yet another part of the infrastructure. Not new accounts, networks, etc., not even an additional database. You can easily start with an existing database by adding the PGVector extension.<\/li>\n\n\n\n<li>Supportive tools are not changing. You run backups, monitoring, and so on. All of these tools might stay relatively untouched. You don\u2019t need to introduce anything new!<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Limitations? Of course!<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This solution has limitations we need to be aware of. It is the relational database with an extension installed, after all. What do we need to be aware of?<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>It is an extension, not the vector database. It mimics vector behavior, but it is not a tool designed to be a vector database.<\/li>\n\n\n\n<li>Large-scale problems. We speak here about millions of embeddings. Latency and memory consumption will be worse than in dedicated solutions.<\/li>\n\n\n\n<li>Indexing might not be as precise as in real vector databases.<\/li>\n\n\n\n<li>Trade-offs between performance and accuracy must be planned and understood.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">When should I consider PostgreSQL with pgvector?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">pgvector on top can be considered as a solution when we want to keep the architecture simple. As we mentioned earlier, it doesn&#8217;t add much to the existing stack.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When scale and performance aren\u2019t the issues, we can consider PostgreSQL with PGVector as a solution for AI workloads, including semantic search over documents, RAG systems for LLM applications, chatbots with internal knowledge bases, and recommendation systems. It should also work well for prototyping AI tools, MVP solutions, or startups that want to enter the market quickly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Can I run PostgreSQL with pgvector at UpCloud?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Of course! UpCloud offers managed databases as a service, with PostgreSQL as one of the options.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When we create the database, we can select extensions, where PGVector is available under the name <strong>vector<\/strong>. This is shown in the picture below.<br><br>To install the extension, we have to log in to the database and run the command<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/upcloud-managed-posgresql-vector-extension-1024x950.png\" alt=\"-\" class=\"wp-image-83159\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>db=&gt;CREATE EXTENSION vector;<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And that\u2019s it! After successful installation, you should see the confirmation information after running a <strong>SELECT<\/strong> command:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/db-select-default-installed-version-1024x256.png\" alt=\"-\" class=\"wp-image-83161\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">If you are interested in the complete installation process, check this tutorial.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">pgvector brings modern semantic search capabilities to a well-established, popular database. It allows teams to easily start building AI applications without increasing engineers\u2019 cognitive load as they learn a completely new toolset.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When the limitations are recognized and addressed, PostgreSQL with pgvector gives teams a head start and enables them to deliver value.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For many real-world applications, such as RAGs, semantic searches, and recommendation engines, this extension makes PostgreSQL a highly effective and pragmatic choice.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Want to test out pgvectors in practice? Check out our tutorial on <a href=\"https:\/\/upcloud.com\/global\/resources\/tutorials\/installing-pgvector-upcloud-managed-postgresql\/\">installing pgvector on UpCloud Managed PostgreSQL<\/a> and get started!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Artificial Intelligence (AI) is changing our world today. It introduced new requirements for our applications, one of which is the use of a vector database. [&hellip;]<\/p>\n","protected":false},"author":100,"featured_media":84451,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"643,745,445,3552,343,529","_relevanssi_noindex_reason":"Blocked by a filter function","footnotes":""},"categories":[28,22,103],"tags":[],"class_list":["post-4080","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-long-reads","category-cloud-infrastructure","category-open-source"],"acf":[],"_links":{"self":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/posts\/4080","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/users\/100"}],"replies":[{"embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/comments?post=4080"}],"version-history":[{"count":8,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/posts\/4080\/revisions"}],"predecessor-version":[{"id":8101,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/posts\/4080\/revisions\/8101"}],"wp:attachment":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/media?parent=4080"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/categories?post=4080"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tags?post=4080"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}