pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
[pgvector/pgvector] issue #653: Table Size Estimate Doesn't Match Actual Size
3+ messages / 2 participants
[nested] [flat]

* [pgvector/pgvector] issue #653: Table Size Estimate Doesn't Match Actual Size
@ 2024-08-22 12:05 "wahajali (@wahajali)" <noreply+wahajali@github.com>
  0 siblings, 0 replies; 3+ messages in thread

From: wahajali (@wahajali) @ 2024-08-22 12:05 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

I have a table with a single vector(1536) column with 500K rows. According to the size estimation provided in the [documentation](https://github.com/pgvector/pgvector?tab=readme-ov-file#vector-type), the size of the table should add up to: 
((4 * 1536 + 8) * 500000) = 3076000000 bytes or ~2.86 GB. However, when I check the table size after insertion using the following command, I get 3978 MB, which is significantly more than the estimation:

```
ann=> SELECT pg_size_pretty(pg_table_size('public.dupe_pg_c')) as table_size;
 table_size 
------------
 3974 MB
(1 row)
```

Following is the table information for reference:
```
ann=> \d dupe_pg_c;
                 Table "public.dupe_pg_c"
  Column   |     Type     | Collation | Nullable | Default 
-----------+--------------+-----------+----------+---------
 embedding | vector(1536) |           |          | 
 
 ann=> select count(*) from public.dupe_pg_c;
 count  
--------
 500000
(1 row)
```

I did also try moving storage to plain `ALTER TABLE public.dupe_pg_c ALTER COLUMN embedding SET STORAGE PLAIN;` but still got similar results.

I am using pgvector v0.7.3. Is there something I am missing? 

^ permalink  raw  [nested|flat] 3+ messages in thread

* Re: [pgvector/pgvector] issue #653: Table Size Estimate Doesn't Match Actual Size
@ 2024-08-22 13:26 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
  1 sibling, 0 replies; 3+ messages in thread

From: jkatz (@jkatz) @ 2024-08-22 13:26 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@wahajali You have to account for the PostgreSQL page size (which defaults to 8KB). For simplicity, as you can only fit one `vector(1536)` per page:

`8192 * 500000` => `4096000000` / (1024 ^ 3) => 3.81GB. (or 3906 MB). The remainder is some overhead around table metadata.

^ permalink  raw  [nested|flat] 3+ messages in thread

* Re: [pgvector/pgvector] issue #653: Table Size Estimate Doesn't Match Actual Size
@ 2024-08-22 13:50 ` "wahajali (@wahajali)" <noreply+wahajali@github.com>
  1 sibling, 0 replies; 3+ messages in thread

From: wahajali (@wahajali) @ 2024-08-22 13:50 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@wahajali closed this.

^ permalink  raw  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2024-08-22 13:50 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-08-22 12:05 [pgvector/pgvector] issue #653: Table Size Estimate Doesn't Match Actual Size "wahajali (@wahajali)" <noreply+wahajali@github.com>
2024-08-22 13:26 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2024-08-22 13:50 ` "wahajali (@wahajali)" <noreply+wahajali@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