pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: rferraton (@rferraton) <noreply+rferraton@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #781: index not used with cte
Date: Sat, 22 Feb 2025 18:01:55 +0000
Message-ID: <gh-pgvector-pgvector-781-c2676330300@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-781@github.com>
References: <gh-pgvector-pgvector-781@github.com>

Materialized does not change anything (with or without enable_seqscan) :

the plan with Materialized and enable_seqscan=off; ==>

```
Limit  (cost=10000083624.76..10000083624.78 rows=10 width=27) (actual time=3701.340..3701.343 rows=10 loops=1)
  Output: a.title, ((vars.qvt_embedding <-> a.chunk_embedding))
  CTE vars
    ->  Index Scan using dbpedia_14_chunk_index_idx on public.dbpedia_14  (cost=0.42..8.44 rows=1 width=18) (actual time=0.062..0.064 rows=1 loops=1)
          Output: dbpedia_14.chunk_embedding
          Index Cond: (dbpedia_14.chunk_index = 473679)
  ->  Sort  (cost=10000083616.31..10000085191.50 rows=630073 width=27) (actual time=3526.610..3526.611 rows=10 loops=1)
        Output: a.title, ((vars.qvt_embedding <-> a.chunk_embedding))
        Sort Key: ((vars.qvt_embedding <-> a.chunk_embedding))
        Sort Method: top-N heapsort  Memory: 26kB
        ->  Nested Loop  (cost=10000000000.00..10000070000.66 rows=630073 width=27) (actual time=0.106..3446.404 rows=630073 loops=1)
              Output: a.title, (vars.qvt_embedding <-> a.chunk_embedding)
              ->  CTE Scan on vars  (cost=0.00..0.02 rows=1 width=32) (actual time=0.066..0.068 rows=1 loops=1)
                    Output: vars.qvt_embedding
              ->  Seq Scan on public.dbpedia_14 a  (cost=10000000000.00..10000062124.73 rows=630073 width=37) (actual time=0.014..130.910 rows=630073 loops=1)
                    Output: a.label, a.title, a.content, a.split, a.content_word_count, a.chunk, a.content_n_chunks, a.chunk_index, a.chunk_word_count, a.chunk_embedding
Planning Time: 0.405 ms
JIT:
  Functions: 8
  Options: Inlining true, Optimization true, Expressions true, Deforming true
  Timing: Generation 1.517 ms (Deform 0.991 ms), Inlining 101.864 ms, Optimization 43.133 ms, Emission 29.729 ms, Total 176.242 ms
Execution Time: 3880.476 ms
```

And yes the index `dbpedia_14_chunk_index_idx` is a unique index.

May be you can re-open the issue : it seams, like you said, that the planner ignore the ivfflat index in this case.



view thread (11+ messages)  latest in thread

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