370 Commits
Author SHA1 Message Date
Andrew Kaneandzeekay 92660f62f1 Added tests for halfvec_avg and halfvec_accum [skip ci]
(cherry picked from commit b818ae17ec8a9f82351f9e6a994b5b271678a2b3)
2026-09-11 13:47:34 -07:00
Andrew Kaneandzeekay c3f4fed396 Fixed buffer size for empty sparsevec with max dimensions (no impact to users due to Postgres allocation alignment) [skip ci]
Co-authored-by: 0xJi3F
(cherry picked from commit 5ffa6d022b211c89bb69bfd1d91cafbfeac8345a)
2026-09-11 13:47:34 -07:00
Andrew Kaneandzeekay a91f1c4c89 Added more tests for vector functions [skip ci]
(cherry picked from commit 751f5a21d8fd76a6ea417f455c01726f84a8d738)
2026-09-11 13:47:34 -07:00
Andrew Kaneandzeekay 7773f5d9c9 Added expected output from previous commit [skip ci]
(cherry picked from commit e859c0a67b3ea4603feedcc2c1b521af940cb60d)
2026-09-11 13:47:34 -07:00
Andrew Kaneandzeekay fdb6a3cfae Added more tests for vector_avg [skip ci]
(cherry picked from commit 3e365966d577c75999b403121c2cc03c513a9c03)
2026-09-11 13:47:34 -07:00
Andrew Kaneandzeekay c858112fb4 Added another test for vector_accum [skip ci]
(cherry picked from commit d5b80b8e48bad3d2c43374c3929fc59ff9b66b39)
2026-09-11 13:47:34 -07:00
Andrew Kaneandzeekay be3ac34a71 Added more tests for vector_combine [skip ci]
(cherry picked from commit 24e40f107cd0d700de92a7273a86ef1ba5e9d245)
2026-09-11 13:47:34 -07:00
Andrew Kaneandzeekay 8306a46090 Added tests for vector_accum [skip ci]
(cherry picked from commit f72795031ba2a103fb378120ffd31026684bbfea)
2026-09-11 13:47:34 -07:00
Andrew Kaneandzeekay 0c1eb41e35 Hardened vector_combine (currently fails at allocation for some sizes) [skip ci]
(cherry picked from commit eb7913b2d95f57458e7d1c5bb8e125eb13298acb)
2026-09-11 13:47:34 -07:00
Andrew Kaneandzeekay 1d5cb54402 Improved tests for rescans / nested loop joins [skip ci]
(cherry picked from commit 721fcf4d2c92e2ef022c42304d547b807cbfbee1)
2026-07-28 09:08:02 -07:00
Andrew Kaneandzeekay cdb5755e18 Fixed tests for Postgres < 16
(cherry picked from commit 2f999115540fdb2f8376df3018c3695bbe306007)
2026-07-28 09:08:02 -07:00
Andrew Kaneandzeekay 16a0bf585e Added tests for rescans / nested loop joins - #1002
Co-authored-by: zthhhhh <[email protected]>
(cherry picked from commit 982593ef013e722998c0fb2e2e1a2c804ed8be20)
2026-07-28 09:08:02 -07:00
Andrew Kaneandzeekay 0a99770a2c Added test for array to halfvec cast [skip ci]
(cherry picked from commit 3e523434f487882964d3e2c91c772f830ef8f060)
2026-07-28 09:08:01 -07:00
Andrew Kane c4dc57c5c6 Added test case for low memory HNSW index builds 2026-02-25 10:41:17 -08:00
Andrew Kane c62389fc3e Simplified test case - resolves #943 2026-01-05 12:42:14 -08:00
Andrew Kane e5d1d3c3d1 Added another test for binary_quantize function [skip ci] 2025-08-29 01:09:18 -07:00
Andrew Kane 865fd940f5 Added tests for iterative index scan with empty index - resolves #679 [skip ci] 2025-02-13 16:28:14 -08:00
Andrew Kane 1d48a605b8 Improved test [skip ci] 2024-10-28 15:54:39 -07:00
Andrew Kane 3523cc6f98 Fixed test 2024-10-28 13:55:26 -07:00
Andrew Kane 46313156de Fixed test [skip ci] 2024-10-27 21:10:51 -07:00
Andrew Kane 6395ccaa52 Updated default value of hnsw.scan_mem_multiplier [skip ci] 2024-10-27 21:05:04 -07:00
Andrew Kane d54760681e Added test for hnsw.scan_mem_multiplier [skip ci] 2024-10-27 20:05:58 -07:00
Andrew Kane c6ecb77152 Renamed iterative_search to iterative_scan 2024-10-27 14:02:22 -07:00
Andrew Kane 960d4eab3b Revert "Renamed iterative_search to iterative_scan"
This reverts commit 58bc222239.
2024-10-24 20:32:07 -07:00
Andrew Kane 58bc222239 Renamed iterative_search to iterative_scan 2024-10-24 20:31:43 -07:00
Andrew Kane 0974d1fa93 Added hnsw.search_mem_multiplier option 2024-10-24 18:02:20 -07:00
Andrew Kane 6d6194bfd9 Updated range and defaults for iterative search parameters 2024-10-21 20:38:50 -07:00
Andrew Kane d1f7d77f4d Improved test output [skip ci] 2024-10-13 17:22:49 -07:00
Andrew Kane fe23c4a7be Improved test output [skip ci] 2024-10-13 17:21:38 -07:00
Andrew Kane e476092b9c Speed up test [skip ci] 2024-10-13 17:12:12 -07:00
Andrew Kane 6e09eaf282 Added test for strict order [skip ci] 2024-10-13 17:04:03 -07:00
Andrew Kane 4505a5edd0 Fixed flaky test [skip ci] 2024-10-11 15:48:19 -07:00
Andrew Kane 7e638c86c4 Use -1 for no limit for ivfflat.max_probes [skip ci] 2024-10-11 11:43:32 -07:00
Andrew Kane b7a596cd5c Simplified GUC names [skip ci] 2024-10-11 11:18:01 -07:00
Andrew Kane ab9c961a5a Added regression tests for iterative search [skip ci] 2024-10-11 11:07:11 -07:00
Andrew Kane e793a63fab Updated GUC names [skip ci] 2024-10-10 23:50:11 -07:00
Andrew Kane e5860ccc63 Added iterative search for HNSW [skip ci] 2024-10-10 18:14:39 -07:00
Andrew Kane 630b0272c2 Added iterative search for IVFFlat [skip ci] 2024-10-10 18:12:27 -07:00
Andrew Kane 9907c183dc Improved IVFFlat vacuum test [skip ci] 2024-10-10 14:24:26 -07:00
Andrew KaneandGitHub 91cb4b74fa Improve total cost for cost estimation (#686) 2024-10-08 12:42:03 -07:00
Andrew Kane 25c2630a5f Added distance filters to cost tests [skip ci] 2024-09-28 14:50:23 -07:00
Andrew Kane 5a65093099 Improved test [skip ci] 2024-09-25 15:58:41 -07:00
Andrew Kane c3df866d4c Added test for IVFFlat costs [skip ci] 2024-09-25 15:53:34 -07:00
Andrew Kane 80db0c7b2c Added test for costs [skip ci] 2024-09-25 15:49:03 -07:00
9371ba7f43 Update HNSW cost estimatation to utilize search and index info (#682)
Previously, the cost estimation formula for a HNSW index scan utilized
a methodology that only factored in the entry level for an HNSW scan
and the "m" index parameter, which reflects the number of tuples (or
vectors) to scan at each step of a HNSW graph traversal. While this
would bias the PostgreSQL query planner to choose an HNSW index scan
over other available paths, this could lead to potential suboptimal
index selection, for example, choosing to use a HNSW index instead of
an available B-tree index that has better selectivity.

The number of tuples scanned during HNSW graph traversal is principally
influenced by these factors:

 * The number of tuples stored in the index
 * `m` - the number of tuples that are scanned in each step of the graph
   traversal
 * `hnsw.ef_search` - which influences the total number of steps it
   takes for the scan to converge on the approximated nearest neighbors

Through testing different source models for vectors, we also observed
that the correlation of vectors in mdoels would impact this convergence.
For this first iteration, we've opted to hardcode a constant scaling
factor and set it to `0.55`, though a future commit may turn this into
a configurable parameter.

The high-level formula for estimating the cost of a HNSW index scan is
as such:

```
(entryLevel * m) + (layer0TuplesMax * layer0Selectivity)
```

where

- `(entryLevel * m)` is the lower bound of tuples to scan, as it
accounts for the graph traversal to layer 0 (L0). (L1 and above has an ef=1)
- `layer0TuplesMax` is an estimate of the maximum number of tuples to
scan at L0. This accounts for tuples that may end up being discarded due
to them already being visited. Testing shows that the number of steps
until converge is similar to the value of `hnsw.ef_search`, thus we can
estimate tuples max at `hnsw.ef_search * m * 2`
- `layer0Selectivity` - estimates the percentage of tuples that will
actually be scanned during the index traversal, multipled by the scaling
factor

In addition to the `m` build parameter and `hsnw.ef_search`, costs
estimates can be influenced by standard PostgreSQL costing parameters,
though adjusting those (e.g. `random_page_cost`) should be done with
care.

Co-authored-by: @ankane
2024-09-25 14:01:33 -07:00
Andrew Kane fb7c86e572 Do not adjust index selectivity based on probes [skip ci] 2024-09-25 13:48:24 -07:00
Andrew Kane 81a7ac3f56 Added test for join with attribute filtering [skip ci] 2024-09-24 23:21:34 -07:00
Andrew Kane 079133f821 Improved test [skip ci] 2024-09-24 23:13:30 -07:00
Andrew Kane 5ef14ea3aa Added test for join [skip ci] 2024-09-24 23:12:27 -07:00
f37b369f00 Added casts for arrays to sparsevec - #604
Co-authored-by: Narek Galstyan <[email protected]>
Co-authored-by: Di Qi <[email protected]>
2024-09-19 19:17:05 -07:00