pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: ankane (@ankane) <noreply+ankane@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #690: Questions Regarding PGVector Index Size and Storage Structure
Date: Thu, 03 Oct 2024 18:41:13 +0000
Message-ID: <gh-pgvector-pgvector-690-c2392083452@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-690@github.com>
References: <gh-pgvector-pgvector-690@github.com>

Hi @kwunhang, they're similar sizes for the same reason as #688. Postgres uses 8KB pages, so in the 768 dimension case, two vectors will fit on a page (3KB each). That leaves around 2KB of space for other data. For IVFFlat, it's empty, and for HNSW, it stores the neighbors.

Neighbors for all levels (for a single element) are stored in a single tuple (in the `indextids` array), starting with the highest level.

```c
typedef struct HnswNeighborTupleData
{
	uint8		type;
	uint8		unused;
	uint16		count;
	ItemPointerData indextids[FLEXIBLE_ARRAY_MEMBER];
}			HnswNeighborTupleData;
```

In your example, `count` and the length of `indextids` would be 9 (3 for level 1, 6 for level 0).

view thread (4+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-690-c2392083452@github.com>
Permalink:  ../gh-pgvector-pgvector-690-c2392083452@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox