Commit Graph
335 Commits
Author SHA1 Message Date
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
Andrew Kane 80b91a1bbc Changed warnings to errors for TAP tests [skip ci] 2024-07-27 12:28:03 -07:00
Andrew Kane b95ce7b660 Updated TAP tests to use PostgreSQL::Test packages [skip ci] 2024-07-27 12:24:15 -07:00
Andrew Kane b68df4e9bc Updated formatting [skip ci] 2024-07-27 08:25:09 -07:00
Andrew Kane f49270db09 Fixed failed to add index item error with sparsevec - fixes #625 2024-07-19 13:54:36 -07:00
Andrew Kane e34e07871a Fixed flaky tests [skip ci] 2024-04-29 13:54:30 -07:00
Andrew Kane bebbe8bc92 Fixed regression test for vector type 2024-04-29 13:48:04 -07:00
Andrew Kane 444401f534 Added basic fuzz testing for input functions 2024-04-27 10:49:45 -07:00
Andrew Kane 43a3dbb470 Use consistent error message for sparsevec index out of bounds [skip ci] 2024-04-26 17:27:09 -07:00
Andrew Kane 49f6ef8a70 Improved sparsevec error messages [skip ci] 2024-04-26 17:11:11 -07:00
Andrew Kane 9581e7cae8 Fixed flaky tests 2024-04-26 13:20:27 -07:00
Andrew Kane ef399e5bbe Improved HNSW recall tests - #535 2024-04-26 13:08:48 -07:00
Andrew Kane afdb05b277 Added test for halfvec sum 2024-04-25 22:03:34 -07:00
Andrew Kane 5b6a96e396 Added aggregate test for halfvec [skip ci] 2024-04-25 21:42:10 -07:00
Andrew Kane 8d3449c63e Reordered TAP tests [skip ci] 2024-04-25 21:08:55 -07:00
Andrew Kane e15016aa59 Reordered TAP tests [skip ci] 2024-04-25 21:04:23 -07:00
Andrew Kane 8dd0a0939f Renamed TAP tests [skip ci] 2024-04-25 20:57:41 -07:00
Andrew Kane 6f3c587df0 Improved copy test [skip ci] 2024-04-25 15:39:47 -07:00
Andrew Kane b4483245b6 Condensed regression tests [skip ci] 2024-04-25 15:35:36 -07:00
Andrew Kane f79e34532a Condensed regression tests [skip ci] 2024-04-25 15:30:38 -07:00
Andrew Kane 313b0ed122 Fixed flaky test [skip ci] 2024-04-25 11:57:40 -07:00
Andrew Kane 1f454ff787 Added test for bit with duplicate centers 2024-04-25 10:29:28 -07:00
Andrew Kane 9620fcfd80 Fixed flaky tests [skip ci] 2024-04-24 22:26:08 -07:00
Andrew Kane 8f728038b3 Increased max sparsevec dimensions to 1B [skip ci] 2024-04-24 11:17:25 -07:00
Andrew Kane 3bf18af035 Improved error messages for sparsevec input 2024-04-24 11:12:28 -07:00
Andrew Kane 312b0c258e Improved tests for sparsevec input [skip ci] 2024-04-24 09:58:27 -07:00
Andrew Kane 96e08e1b6d Switched to strtoint for sparsevec input 2024-04-24 09:56:09 -07:00
Andrew Kane 540bdf784e Added more tests for subvector function [skip ci] 2024-04-24 01:31:50 -07:00
Andrew Kane 745b5f0264 Added more tests for subvector function [skip ci] 2024-04-24 01:28:25 -07:00
Heikki LinnakangasandGitHub e452e0afc7 Fix integer overflow in subvector() function (#530)
`end = start + count` can overflow if `start` is very large. That
leads to a segfault later in the function. Add test case for it.
2024-04-24 01:20:16 -07:00
Andrew Kane 2ea421470e Improved test [skip ci] 2024-04-23 20:42:30 -07:00
Andrew Kane 9474a82f9b Improved test [skip ci] 2024-04-23 20:41:11 -07:00
Andrew Kane 61e7566ec7 Improved tests for l2_norm [skip ci] 2024-04-23 20:38:22 -07:00
Andrew Kane bf87c5607c Improved tests for sparsevec distance functions [skip ci] 2024-04-23 20:29:04 -07:00
Andrew Kane 939bcbe0ca Increased max sparsevec dimensions to 1M [skip ci] 2024-04-23 17:47:11 -07:00
Andrew Kane 8d903b6858 Added more tests for vector distance functions [skip ci] 2024-04-22 15:53:13 -07:00