Use the vector extension, version 0.5.0.google-1 or later, which includes
pgvector functions and operators, to store generated embeddings as vector values. This
is a version of pgvector that Google has extended with optimizations specific
to AlloyDB.
CREATEEXTENSIONIFNOTEXISTSvector;
Store generated embeddings
Ensure that you have already created a table in your AlloyDB database.
To store vector embeddings, do the following:
Create a vector[] column in your table to store your embeddings:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 UTC."],[[["\u003cp\u003eAlloyDB can be used as a vector database by utilizing the \u003ccode\u003evector\u003c/code\u003e extension, which includes \u003ccode\u003epgvector\u003c/code\u003e functions and operators for storing embeddings.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003evector\u003c/code\u003e extension, version \u003ccode\u003e0.5.0.google-1\u003c/code\u003e or later, is required and has Google-specific optimizations for AlloyDB to efficiently manage vector data.\u003c/p\u003e\n"],["\u003cp\u003eTo store embeddings, add a \u003ccode\u003evector[]\u003c/code\u003e column to your table with \u003ccode\u003eALTER TABLE\u003c/code\u003e, specifying the dimensions supported by your embedding model.\u003c/p\u003e\n"],["\u003cp\u003eYou can copy vectors into the designated column using a \u003ccode\u003e.csv\u003c/code\u003e file with the \u003ccode\u003eCOPY\u003c/code\u003e command.\u003c/p\u003e\n"],["\u003cp\u003eAfter storing embeddings, you can improve query performance by creating indexes with the \u003ccode\u003evector\u003c/code\u003e extension or the \u003ccode\u003ealloydb_scann\u003c/code\u003e extension.\u003c/p\u003e\n"]]],[],null,[]]