fix(pgvector): make doc deletion query faster#289
Open
kyteinsky wants to merge 5 commits into
Open
Conversation
02b8435 to
f03c10a
Compare
kyteinsky
commented
Mar 20, 2026
| f'{DOCUMENTS_TABLE_NAME}.source_id', | ||
| ondelete='CASCADE', | ||
| ), | ||
| index=True, |
Contributor
Author
There was a problem hiding this comment.
DB migration needs to be done for this to happen on existing installations.
index the source_id column in the access_list table Signed-off-by: Anupam Kumar <kyteinsky@gmail.com>
Signed-off-by: Anupam Kumar <kyteinsky@gmail.com>
f03c10a to
37bfcc6
Compare
Contributor
Author
|
verified again the index actually does improve things: after: the difference in time to pay attention to is index can be manually created like so: |
…ir fails Signed-off-by: kyteinsky <kyteinsky@gmail.com>
Signed-off-by: kyteinsky <kyteinsky@gmail.com>
…onfig Signed-off-by: kyteinsky <kyteinsky@gmail.com>
Comment on lines
+95
to
+99
| - name: Enable PostgreSQL slow query logging and auto_explain | ||
| run: | | ||
| PG_CONTAINER=$(docker ps -q --filter "ancestor=pgvector/pgvector:pg17") | ||
| docker exec $PG_CONTAINER bash -c "\ | ||
| cat >> /var/lib/postgresql/data/postgresql.conf <<EOF |
Comment on lines
+112
to
+117
| # file-based logging | ||
| logging_collector = on | ||
| log_directory = '/var/log/pg_log' | ||
| log_filename = 'postgresql.log' | ||
| log_file_mode = 0644 | ||
| EOF" |
Comment on lines
+420
to
+421
| PG_CONTAINER=$(docker ps -q --filter "ancestor=pgvector/pgvector:pg17") | ||
| docker exec $PG_CONTAINER cat /var/log/pg_log/postgresql.log |
Comment on lines
+28
to
+31
| f'Warning: could not read {version_info_path}, assuming no previous version was installed: {e}', | ||
| flush=True, | ||
| ) | ||
| return (0, False) |
| except OSError as e: | ||
| print(f'Error: could not list repair directory to get all the eligible repairs: {e}', flush=True) | ||
| raise | ||
| repair_filenames = [f for f in all_filenames if f.startswith('repair') and f.endswith('.py')] |
Comment on lines
+25
to
+28
| conn.execute(sa.text( | ||
| 'CREATE INDEX IF NOT EXISTS idx_access_list_source_id ON access_list (source_id)' | ||
| )) | ||
| conn.commit() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CI logging for slow queries has also been enabled, not sure if we will see that in the CI though.
Sample output for the slow deletion query where a missing index on the
source_idforeign key in access_list table was the culprit.Calculated time: 3.495 + 0.310 + 0.129 = 3.934 ms
Actual time: 201177.123 ms or 201 s
(put the chunking part in a different PR)