{"id":8068,"date":"2026-07-10T16:03:39","date_gmt":"2026-07-10T15:03:39","guid":{"rendered":"https:\/\/upcloud.com\/global\/?post_type=tutorial&#038;p=8068"},"modified":"2026-07-10T16:03:39","modified_gmt":"2026-07-10T15:03:39","slug":"installing-pgvector-upcloud-managed-postgresql","status":"publish","type":"tutorial","link":"https:\/\/upcloud.com\/global\/resources\/tutorials\/installing-pgvector-upcloud-managed-postgresql\/","title":{"rendered":"Installing pgvector on UpCloud Managed PostgreSQL"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">What is pgvector?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Pgvector is a PostgreSQL extension that allows us to use relational databases as vector databases. This means that we are able to use AI applications like RAGs, recommendation systems, and so on with traditional, well-known databases, without adding another piece into our architecture and without adding more cognitive load to the teams &#8211; they already know how to work with PostgreSQL.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We covered the basics of pgvector and its benefits in <a href=\"https:\/\/upcloud.com\/global\/blog\/ai-search-postgresql-database-pgvector-extension\/\">our article about using pgvectors for AI search on PostgreSQL<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing pgvector extension<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In this tutorial, we will install pgvector on UpCloud\u2019s Managed PostgreSQL database and confirm that our extension works. To go forward and see how vectors work with this extension, follow this tutorial.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Prerequisites<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To install this extension on a PostgreSQL database, we need a database. This tutorial requires that you already have one up and running. If you are new to this field, we have you covered. Follow the tutorial on <a href=\"https:\/\/upcloud.com\/global\/docs\/guides\/set-up-upcloud-managed-databases\/\">how to deploy Managed Databases at UpCloud<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">PostgreSQL extensions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">UpCloud\u2019s DBaaS for PostgreSQL offers many extensions we can easily use with our database. These extensions add new capabilities to the database, but don&#8217;t change the engine itself. It is still PostgreSQL.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to install the pgvector extension in UpCloud\u2019s managed database?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The process is very easy and straightforward. We will go through the Hub to check whether the extension exists and which versions are available, then we will log in to the database and enable the extension. Finally, we will check whether the extension is ready to use.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Checking extensions through UpCloud\u2019s Hub<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In the image below, we can see a running database seen in UpCloud\u2019s Hub.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/1-managed-databases-1024x383.png\" alt=\"-\" class=\"wp-image-84464\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">After we click the database tile, we go to the details for this database instance. For us, the interesting section is at the bottom of the page, under the button shown in the image.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/2-check-postgresql-extensions.png\" alt=\"-\" class=\"wp-image-84466\" style=\"width:291px;height:auto\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Under this button, we can see all the extensions prepared by UpCloud\u2019s team, which we can easily install.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The list is quite large and contains extensions for many use cases we might have installed to enable our workloads.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/3-available-postgresql-extensions-694x1024.png\" alt=\"-\" class=\"wp-image-84467\" style=\"aspect-ratio:0.6777465268899685;width:399px;height:auto\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The list can be limited to specific extensions using the \u201csearch\u201d field. Every extension shows its available version. In most cases, there will be only one version, but extensions allow us to select different versions. This might be important for us when we have architectural needs that require pinning specific software versions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">UpCloud offers many versions of the PostgreSQL engine. That is why we can search extensions by engine version.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As the list is alphabetical, our extension will be somewhere at the bottom. We need to search for the <em>vector<\/em> extension.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/4-posgresql-vector-extension.png\" alt=\"-\" class=\"wp-image-84468\" style=\"aspect-ratio:4.370838313129589;width:415px;height:auto\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Now that we know that the extension is available, it is time to log in to the database and enable it!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Enabling the extension<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Before we log in to the database, we need to have a tool installed that supports it. This tool is <strong>pgsql<\/strong>, and it is widely used across platforms.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We use a Ubuntu machine in this tutorial, running on UpCloud. To install the extension, we need to run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">sudo apt install postgresql-client -y<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After this, we are ready to connect to the database. In the hub, we can find the connection string for private connection under the Connections section. We select the Private tab if it is not selected.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/5-managed-databases-connection-details-1024x404.png\" alt=\"-\" class=\"wp-image-84470\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">A utility network lets us connect to internal resources on our account, but for better security, we can segregate these by configuring SDN Connections.<br>We copy the string and enter it in the console:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">psql postgres:\/\/upadmin:AVNS_5iR9rkGHu3JQI9SisZi@postgres-ydmzzdmsgsqh.db.upclouddatabases.com:11569\/defaultdb?sslmode=require<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We should notice the user and the randomized password provided in the connection string.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If we were successful, the image shows the state we should see: <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/6-connect-managed-databases-1024x165.png\" alt=\"-\" class=\"wp-image-84473\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">From the level of the database, we can check if the extension is available, using<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">defaultdb=&gt; SELECT * FROM pg_available_extensions WHERE name = \u2018vector\u2019;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the extension is available, this is what we will see:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/7-pg-available-extensions-vector-1024x173.png\" alt=\"-\" class=\"wp-image-84474\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Confirmed, an extension is available. Now it is time to confirm if the extension is enabled:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">defaultdb=&gt; SELECT * FROM pg_extension WHERE extname = \u2018vector\u2019;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the response is empty, the extension is not enabled. The image shows exactly this situation:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/8-pg-extension-vector-1024x151.png\" alt=\"-\" class=\"wp-image-84475\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Ok, we are ready to enable the extension.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This command will enable pgvector in our PostgreSQL database:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">defaultdb=&gt; CREATE EXTENSION IF NOT EXISTS vector;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This will enable the extension, and once that&#8217;s done, we can start building our vector database!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/9-enable-vector-extension-1024x91.png\" alt=\"-\" class=\"wp-image-84477\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">To be 100% sure that the extension is enabled and works, we can run this command again:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">defaultdb=&gt; SELECT * FROM pg_extension WHERE extname = \u2018vector\u2019;<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/10-pg-extension-vector-enabled-1024x172.png\" alt=\"-\" class=\"wp-image-84479\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Next steps<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">We enabled the pgvector extension in PostgreSQL and are ready to run our vector workloads. To very quickly check if pgvector is enabled, we can run the command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">defaultdb=&gt; SELECT \u2018[1,2,3]\u2019::vector;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The correct response is shown in the image below. If the extension is not working, we will receive an error in the response.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/upcloud.com\/media\/11-defaultdb-select-vector-1024x170.png\" alt=\"-\" class=\"wp-image-84481\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">To disable the extension, we need to run the command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">defaultdb=&gt; DROP EXTENSION vector;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">UpCloud offers us a very easy and almost instant way to install the <code>pgvector<\/code> extension. In a few minutes, we can convert well-known, established databases like PostgreSQL into vector databases suitable for AI workloads such as RAG, knowledge bases, and recommendation systems. And all without any additional costs!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Are you ready to test this yourself? Register the account on <a href=\"https:\/\/upcloud.com\">UpCloud<\/a> or log in to <a href=\"https:\/\/hub.upcloud.com\/dashboard\">Hub<\/a> and follow this tutorial! <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do you have questions? Our team is happy to <a href=\"https:\/\/upcloud.com\/global\/contact\/#form\">chat<\/a>!<\/p>\n","protected":false},"author":100,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","community-category":[244,226],"class_list":["post-8068","tutorial","type-tutorial","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial\/8068","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial"}],"about":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/types\/tutorial"}],"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=8068"}],"version-history":[{"count":5,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial\/8068\/revisions"}],"predecessor-version":[{"id":8103,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial\/8068\/revisions\/8103"}],"wp:attachment":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/media?parent=8068"}],"wp:term":[{"taxonomy":"community-category","embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/community-category?post=8068"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}