pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: xiaojunxiang2023 (@xiaojunxiang2023) <noreply+xiaojunxiang2023@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] issue #811: Why does PgVector store 0.004438427742570639 only up to 0.0044384277, while printing a float in C Test Code can show the full value?
Date: Fri, 28 Mar 2025 10:54:13 +0000
Message-ID: <gh-pgvector-pgvector-811@github.com> (raw)

My embedding model generates numbers like 0.004438427742570639, but when I store them in pgvector and query them back, they are only displayed as 0.0044384277. 
```
DROP TABLE xjx_db5.book;
CREATE TABLE xjx_db5.book(
       id float4, -- 即 float4字节, 32Bit, 即 C的 float
       price float8,-- 即 float8字节, 64Bit,即 C的 double
       emb vector(2)
);

INSERT INTO xjx_db5.book(id,price, emb)
VALUES (0.004438427742570639,
        0.004438427742570639,
        '[99,0.004438427742570639]');
SELECT * FROM xjx_db5.book;

      id      |        price         |        emb        
--------------+----------------------+-------------------
 0.0044384277 | 0.004438427742570639 | [99,0.0044384277]
(1 row)
```

I tested printf in C, it can show the full value.
```
root@mme-perf-test-54dc8694d7-prbl8:/opt/mme# cat test.c 
#include <stdio.h>

int main() {
    float a = 0.004438427742570639f;
    printf("Float  value: %.18f\n", a);
    return 0;
}
root@mme-perf-test-54dc8694d7-prbl8:/opt/mme# gcc test.c -o test.o
root@mme-perf-test-54dc8694d7-prbl8:/opt/mme# ./test.o 
Float  value: 0.004438427742570639

```



I have some questions:

- How can I increase the precision of vectors in pgvector?

- If I increase the precision, will it impact performance?

view thread (4+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-811@github.com>
Permalink:  ../gh-pgvector-pgvector-811@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