-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathvector_bulk.result
More file actions
44 lines (44 loc) · 1.81 KB
/
Copy pathvector_bulk.result
File metadata and controls
44 lines (44 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#
# Test memory budget fallback during MHNSW bulk insert
#
# 1. Normal bulk insert works when memory budget is large enough
create table t1 (id int auto_increment primary key, v vector(3) not null);
insert into t1 (v) values (x'000000000000000000000000'),
(x'0000803f0000000000000000'),
(x'000000000000803f00000000'),
(x'00000000000000000000803f');
alter table t1 add vector index (v);
show warnings;
Level Code Message
# Test search using the successfully bulk-built index
select id, vec_distance_euclidean(v, x'0000803f0000000000000000') d from t1 order by d limit 2;
id d
2 0
1 1
drop table t1;
# 2. Bulk insert falls back to normal insert when mhnsw_max_cache_size is small
set @old_cache_size= @@global.mhnsw_max_cache_size;
set global mhnsw_max_cache_size= 1048576;
set max_recursive_iterations= 300;
create table t1 (id int auto_increment primary key, v vector(3000) not null);
insert into t1 (v)
with recursive cte as (
select 1 as n
union all
select n + 1 from cte where n < 115
)
select repeat(x'00', 12000) from cte;
insert into t1 (id, v) values (999, concat(repeat(x'00', 11996), x'0000803f'));
# Adding index with small cache size should trigger fallback and show a warning
alter table t1 add vector index (v) m=200;
Warnings:
Note 1105 MHNSW: Bulk insert disabled because estimated memory usage (estimated_mem) exceeds mhnsw_max_cache_size (1048576). Falling back to normal insert.
show warnings;
Level Code Message
Note 1105 MHNSW: Bulk insert disabled because estimated memory usage (estimated_mem) exceeds mhnsw_max_cache_size (1048576). Falling back to normal insert.
# Test search using the fallback-built index to ensure it is healthy and correct
select id, vec_distance_euclidean(v, concat(repeat(x'00', 11996), x'0000803f')) d from t1 order by d limit 1;
id d
999 0
drop table t1;
set global mhnsw_max_cache_size= @old_cache_size;