2023-06-08 08:10:40 +00:00
|
|
|
--- Negative tests ---
|
|
|
|
--- Test default GRANULARITY (should be 100 mio. for annoy)---
|
|
|
|
CREATE TABLE default.tab\n(\n `id` Int32,\n `vector` Array(Float32),\n INDEX annoy_index vector TYPE annoy GRANULARITY 100000000\n)\nENGINE = MergeTree\nORDER BY id\nSETTINGS index_granularity = 8192
|
|
|
|
CREATE TABLE default.tab\n(\n `id` Int32,\n `vector` Array(Float32),\n INDEX annoy_index vector TYPE annoy GRANULARITY 100000000\n)\nENGINE = MergeTree\nORDER BY id\nSETTINGS index_granularity = 8192
|
|
|
|
--- Test with Array, GRANULARITY = 1, index_granularity = 5 ---
|
2023-05-25 21:57:17 +00:00
|
|
|
WHERE type, L2Distance, check that index is used
|
|
|
|
Expression ((Projection + Before ORDER BY))
|
|
|
|
Limit (preliminary LIMIT (without OFFSET))
|
|
|
|
ReadFromMergeTree (default.tab)
|
|
|
|
Indexes:
|
|
|
|
PrimaryKey
|
|
|
|
Condition: true
|
|
|
|
Parts: 1/1
|
2023-06-05 10:26:45 +00:00
|
|
|
Granules: 3/3
|
2023-05-25 21:57:17 +00:00
|
|
|
Skip
|
|
|
|
Name: annoy_index
|
|
|
|
Description: annoy GRANULARITY 1
|
|
|
|
Parts: 1/1
|
2023-06-05 10:26:45 +00:00
|
|
|
Granules: 1/3
|
2023-05-25 21:57:17 +00:00
|
|
|
ORDER BY type, L2Distance, check that index is used
|
|
|
|
Expression (Projection)
|
|
|
|
Limit (preliminary LIMIT (without OFFSET))
|
|
|
|
Sorting (Sorting for ORDER BY)
|
|
|
|
Expression (Before ORDER BY)
|
|
|
|
ReadFromMergeTree (default.tab)
|
|
|
|
Indexes:
|
|
|
|
PrimaryKey
|
|
|
|
Condition: true
|
|
|
|
Parts: 1/1
|
2023-06-05 10:26:45 +00:00
|
|
|
Granules: 3/3
|
2023-05-25 21:57:17 +00:00
|
|
|
Skip
|
|
|
|
Name: annoy_index
|
|
|
|
Description: annoy GRANULARITY 1
|
|
|
|
Parts: 1/1
|
2023-06-05 10:26:45 +00:00
|
|
|
Granules: 3/3
|
2023-06-08 08:10:40 +00:00
|
|
|
Reference ARRAYs with non-matching dimension are rejected
|
|
|
|
Special case: MaximumDistance is negative
|
|
|
|
WHERE type, L2Distance
|
|
|
|
Special case: setting annoy_index_search_k_nodes
|
|
|
|
Special case: setting max_limit_for_ann_queries
|
2023-05-25 21:03:50 +00:00
|
|
|
Expression (Projection)
|
|
|
|
Limit (preliminary LIMIT (without OFFSET))
|
|
|
|
Sorting (Sorting for ORDER BY)
|
|
|
|
Expression (Before ORDER BY)
|
|
|
|
ReadFromMergeTree (default.tab)
|
|
|
|
Indexes:
|
|
|
|
PrimaryKey
|
|
|
|
Condition: true
|
|
|
|
Parts: 1/1
|
2023-06-05 10:26:45 +00:00
|
|
|
Granules: 3/3
|
2023-06-08 08:10:40 +00:00
|
|
|
--- Test with Tuple, GRANULARITY = 1, index_granularity = 5 ---
|
2023-06-05 10:49:45 +00:00
|
|
|
WHERE type, L2Distance, check that index is used
|
|
|
|
Expression ((Projection + Before ORDER BY))
|
|
|
|
Limit (preliminary LIMIT (without OFFSET))
|
|
|
|
ReadFromMergeTree (default.tab)
|
|
|
|
Indexes:
|
|
|
|
PrimaryKey
|
|
|
|
Condition: true
|
|
|
|
Parts: 1/1
|
|
|
|
Granules: 3/3
|
|
|
|
Skip
|
|
|
|
Name: annoy_index
|
|
|
|
Description: annoy GRANULARITY 1
|
|
|
|
Parts: 1/1
|
|
|
|
Granules: 1/3
|
|
|
|
ORDER BY type, L2Distance, check that index is used
|
|
|
|
Expression (Projection)
|
|
|
|
Limit (preliminary LIMIT (without OFFSET))
|
|
|
|
Sorting (Sorting for ORDER BY)
|
|
|
|
Expression (Before ORDER BY)
|
|
|
|
ReadFromMergeTree (default.tab)
|
|
|
|
Indexes:
|
|
|
|
PrimaryKey
|
|
|
|
Condition: true
|
|
|
|
Parts: 1/1
|
|
|
|
Granules: 3/3
|
|
|
|
Skip
|
|
|
|
Name: annoy_index
|
|
|
|
Description: annoy GRANULARITY 1
|
|
|
|
Parts: 1/1
|
|
|
|
Granules: 3/3
|
2023-06-08 08:10:40 +00:00
|
|
|
--- Test non-default metric (cosine distance) + non-default NumTrees (200) ---
|
|
|
|
--- Test with Array, GRANULARITY = 2, index_granularity = 4 ---
|
|
|
|
WHERE type, L2Distance, check that index is used
|
|
|
|
Expression ((Projection + Before ORDER BY))
|
|
|
|
Limit (preliminary LIMIT (without OFFSET))
|
|
|
|
ReadFromMergeTree (default.tab)
|
|
|
|
Indexes:
|
|
|
|
PrimaryKey
|
|
|
|
Condition: true
|
|
|
|
Parts: 1/1
|
|
|
|
Granules: 4/4
|
|
|
|
Skip
|
|
|
|
Name: annoy_index
|
|
|
|
Description: annoy GRANULARITY 2
|
|
|
|
Parts: 0/1
|
2023-08-21 15:13:02 +00:00
|
|
|
Granules: 0/4
|
2023-06-08 08:10:40 +00:00
|
|
|
ORDER BY type, L2Distance, check that index is used
|
2023-06-05 10:49:45 +00:00
|
|
|
Expression (Projection)
|
|
|
|
Limit (preliminary LIMIT (without OFFSET))
|
|
|
|
Sorting (Sorting for ORDER BY)
|
|
|
|
Expression (Before ORDER BY)
|
|
|
|
ReadFromMergeTree (default.tab)
|
|
|
|
Indexes:
|
|
|
|
PrimaryKey
|
|
|
|
Condition: true
|
|
|
|
Parts: 1/1
|
2023-06-08 08:10:40 +00:00
|
|
|
Granules: 4/4
|
|
|
|
Skip
|
|
|
|
Name: annoy_index
|
|
|
|
Description: annoy GRANULARITY 2
|
|
|
|
Parts: 1/1
|
2023-08-21 15:13:02 +00:00
|
|
|
Granules: 2/4
|
2023-06-08 08:10:40 +00:00
|
|
|
--- Test with Array, GRANULARITY = 4, index_granularity = 4 ---
|
|
|
|
WHERE type, L2Distance, check that index is used
|
|
|
|
Expression ((Projection + Before ORDER BY))
|
|
|
|
Limit (preliminary LIMIT (without OFFSET))
|
|
|
|
ReadFromMergeTree (default.tab)
|
|
|
|
Indexes:
|
|
|
|
PrimaryKey
|
|
|
|
Condition: true
|
|
|
|
Parts: 1/1
|
|
|
|
Granules: 4/4
|
|
|
|
Skip
|
|
|
|
Name: annoy_index
|
|
|
|
Description: annoy GRANULARITY 4
|
|
|
|
Parts: 0/1
|
2023-08-21 15:13:02 +00:00
|
|
|
Granules: 0/4
|
2023-06-08 08:10:40 +00:00
|
|
|
ORDER BY type, L2Distance, check that index is used
|
|
|
|
Expression (Projection)
|
|
|
|
Limit (preliminary LIMIT (without OFFSET))
|
|
|
|
Sorting (Sorting for ORDER BY)
|
|
|
|
Expression (Before ORDER BY)
|
|
|
|
ReadFromMergeTree (default.tab)
|
|
|
|
Indexes:
|
|
|
|
PrimaryKey
|
|
|
|
Condition: true
|
|
|
|
Parts: 1/1
|
|
|
|
Granules: 4/4
|
|
|
|
Skip
|
|
|
|
Name: annoy_index
|
|
|
|
Description: annoy GRANULARITY 4
|
|
|
|
Parts: 1/1
|
2023-08-23 12:44:21 +00:00
|
|
|
Granules: 1/4
|
|
|
|
--- Test correctness of Annoy index with > 1 mark
|
|
|
|
1 [1,0,0,0]
|
|
|
|
9000 [9000,0,0,0]
|
|
|
|
1 (1,0,0,0)
|
|
|
|
9000 (9000,0,0,0)
|