Fix: pgvector indices not created for multiple knowledge tables due to non-unique index names #13865

Closed
opened 2026-02-21 19:14:16 -05:00 by yindo · 1 comment
Owner

Originally created by @k-kayashima on GitHub (May 14, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.3.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Create a knowledge database using pgvector
  2. Upload and process the first knowledge file/document - index is properly created
  3. Upload and process a second knowledge file/document - no index is created
  4. Check the database and observe that only the first knowledge table has an index

✔️ Expected Behavior

All knowledge tables should have proper indices created

Actual Behavior

Only the first knowledge table has an index, subsequent tables are missing indices

Originally created by @k-kayashima on GitHub (May 14, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.3.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1. Create a knowledge database using pgvector 2. Upload and process the first knowledge file/document - index is properly created 3. Upload and process a second knowledge file/document - no index is created 4. Check the database and observe that only the first knowledge table has an index ### ✔️ Expected Behavior All knowledge tables should have proper indices created ### ❌ Actual Behavior Only the first knowledge table has an index, subsequent tables are missing indices
yindo added the 🐞 bug label 2026-02-21 19:14:16 -05:00
yindo closed this issue 2026-02-21 19:14:16 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (May 14, 2025):

Hello @k-kayashima! I'm Dosu, here to help you with bugs, questions, and anything else you need while you wait for a human maintainer. Let's get started!

The issue with pgvector indices not being created for multiple knowledge tables in a self-hosted Dify version 1.3.0 setup is due to the use of a fixed index name embedding_cosine_v1_idx in the SQL statement for creating indices. This results in a conflict when multiple tables attempt to create an index with the same name. To resolve this, the index name should be made unique for each table, possibly by incorporating the table name or another unique identifier into the index name [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (May 14, 2025): <!-- Greeting --> Hello @k-kayashima! I'm [Dosu](https://dosu.dev), here to help you with bugs, questions, and anything else you need while you wait for a human maintainer. Let's get started! <!-- Answer --> The issue with pgvector indices not being created for multiple knowledge tables in a self-hosted Dify version 1.3.0 setup is due to the use of a fixed index name `embedding_cosine_v1_idx` in the SQL statement for creating indices. This results in a conflict when multiple tables attempt to create an index with the same name. To resolve this, the index name should be made unique for each table, possibly by incorporating the table name or another unique identifier into the index name <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/rag/datasource/vdb/pgvector/pgvector.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/9d8e7425-4472-485e-875e-93ad880f5db8?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/9d8e7425-4472-485e-875e-93ad880f5db8?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/9d8e7425-4472-485e-875e-93ad880f5db8?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/9d8e7425-4472-485e-875e-93ad880f5db8?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/9d8e7425-4472-485e-875e-93ad880f5db8?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/9d8e7425-4472-485e-875e-93ad880f5db8?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/9d8e7425-4472-485e-875e-93ad880f5db8?feedback_type=other)</sup>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#13865