> For the complete documentation index, see [llms.txt](https://leejaelll.gitbook.io/dev_jaell/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://leejaelll.gitbook.io/dev_jaell/database/postgresql/pgvector.md).

# pgvector

### install vector extension

{% hint style="danger" %}
***ERROR: Unique constraint failed on the fields: (****`userId`****)***

could not open extension control file "/opt/homebrew/share/postgresql\@14/extension/vector.control": No such file or directory

👉🏻 vector extension 기능이 설치되어있지 않을 때 발생
{% endhint %}

[pgvector 공식문서](https://github.com/pgvector/pgvector)&#x20;

```bash
cd /tmp
git clone --branch v0.6.2 https://github.com/pgvector/pgvector.git
cd pgvector
make
make install # may need sudo
```

postgres로 접속한 후, vector extension을 생성한다.&#x20;

```bash
psql -U postgres

CREATE EXTENSION vector;
```

{% hint style="warning" %}
***ERROR: permission denied to create extension "vector"***\
\
👉🏻 vector를 만들 권한이 없는 user일 경우 발생
{% endhint %}

<figure><img src="https://1584857390-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvoqcCoqFcnxmEmzndTAj%2Fuploads%2FmczAthMPtrSZMZ8QxWKR%2F%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA%202024-04-01%20%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE%205.57.21.png?alt=media&amp;token=dd1781f3-8726-4b45-9b86-b4a5949d1624" alt=""><figcaption></figcaption></figure>

user role에 `Superuser`가 있는지 확인 후, 없다면 `ALTER USER myuser with superuser;` 실행 ➡️ 권한 등록&#x20;
