Skip to content

[PGVector] Unnecessary columns queried leads to high latency #237

@JoshuaPostel

Description

@JoshuaPostel

results: List[Any] = (
session.query(
self.EmbeddingStore,
self.distance_strategy(embedding).label("distance"),
)
.filter(*filter_by)
.order_by(sqlalchemy.asc("distance"))
.join(
self.CollectionStore,
self.EmbeddingStore.collection_id == self.CollectionStore.uuid,
)
.limit(k)
.all()
)

This query returns the embedding column which is expensive to deserialize into a python object and AFAICT is not used downstream. From my observations benchmarking against an equivalent query without the embedding column, this costs ~150ms (1024 dimension vector, k=30).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions