From: jkatz (@jkatz) <noreply+jkatz@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #661: IVFFLAT QPS too low
Date: Tue, 27 Aug 2024 00:47:22 +0000
Message-ID: <gh-pgvector-pgvector-661-c2311357875@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-661@github.com>
References: <gh-pgvector-pgvector-661@github.com>
@bantmen Assuming you've performed your index build and haven't added any data to the index since, the vectors associated with a list should be colocated - but note given the size of these vectors, PostgreSQL will only store one per index page.
For your second question, it depends on what your query looks like - if you're including the vector itself in your select list (`SELECT ... , vector_column , ...`), PostgreSQL will have to fetch the vector from the table. You mentioned you're using TOAST - if you're not planning to return the vector itself, then TOAST should make sense. If you're just using the vector for the distance operation (`SELECT ... FROM ... ORDER BY vector_column <=> $1`), then you shouldn't be loading the vectors stored as part of the table into memory. Given you're TOASTing the vectors, you'd have to check the associated TOAST table to see what data is in resident cache.
(Separately, if you're using an Amazon Aurora instance, you could evaluate using an [Optimized Reads](https://aws.amazon.com/blogs/database/accelerate-generative-ai-workloads-on-amazon-aurora-with-optim...) instance, e.g. an r6gd.2xlarge - if your workload characteristics match the target profile, this will reduce fetches to network storage as data evicted from memory may be cached in the local NVMe.)