pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
[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?
4+ messages / 2 participants
[nested] [flat]

* [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?
@ 2025-03-28 10:54 "xiaojunxiang2023 (@xiaojunxiang2023)" <noreply+xiaojunxiang2023@github.com>
  0 siblings, 0 replies; 4+ messages in thread

From: xiaojunxiang2023 (@xiaojunxiang2023) @ 2025-03-28 10:54 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

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?

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

* Re: [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?
@ 2025-03-28 11:05 ` "xiaojunxiang2023 (@xiaojunxiang2023)" <noreply+xiaojunxiang2023@github.com>
  2 siblings, 0 replies; 4+ messages in thread

From: xiaojunxiang2023 (@xiaojunxiang2023) @ 2025-03-28 11:05 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@xiaojunxiang2023 renamed this.

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

* Re: [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?
@ 2025-03-28 15:49 ` "ankane (@ankane)" <noreply+ankane@github.com>
  2 siblings, 0 replies; 4+ messages in thread

From: ankane (@ankane) @ 2025-03-28 15:49 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Hi @xiaojunxiang2023, see #672.

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

* Re: [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?
@ 2025-03-28 15:49 ` "ankane (@ankane)" <noreply+ankane@github.com>
  2 siblings, 0 replies; 4+ messages in thread

From: ankane (@ankane) @ 2025-03-28 15:49 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@ankane closed this.

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


end of thread, other threads:[~2025-03-28 15:49 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-03-28 10:54 [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? "xiaojunxiang2023 (@xiaojunxiang2023)" <noreply+xiaojunxiang2023@github.com>
2025-03-28 11:05 ` "xiaojunxiang2023 (@xiaojunxiang2023)" <noreply+xiaojunxiang2023@github.com>
2025-03-28 15:49 ` "ankane (@ankane)" <noreply+ankane@github.com>
2025-03-28 15:49 ` "ankane (@ankane)" <noreply+ankane@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