From: harikennedy (@harikennedy) <noreply+harikennedy@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #766: High LWLock Contention During Concurrent HNSW Index Scans
Date: Sat, 25 Jan 2025 20:33:48 +0000
Message-ID: <gh-pgvector-pgvector-766-c2614091304@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-766@github.com>
References: <gh-pgvector-pgvector-766@github.com>
Thanks for the response!
I’d like to clarify that the issue doesn’t appear to be CPU saturation. During high concurrency workloads on a db.r5.8xlarge instance, CPU usage remains around 30–50%, while AWS Performance Insights shows LWLock:LockManager wait events dominating the load.

Shared locks like LockPage(..., HNSW_SCAN_LOCK, ShareLock) allow concurrent reads, but at high concurrency, the overhead of acquiring and releasing these locks seems to cause contention. This is evident as query throughput saturates at ~32 sessions and increasing concurrency beyond this only increases LWLock contention.