更新时间:2026-07-20 GMT+08:00
分享

常见问题

创建表时,报错dimensions for type vector cannot exceed 4096

答:创建表时,需指定向量维度,且不超过4096维。

gaussdb=#  CREATE TABLE t2 (a int, repr floatvector(100));

创建表时,报错The "boolvector" type declaration for column must have length set

答:创建表时,需要指定向量维度。
gaussdb=#  CREATE TABLE t1 (a int, repr floatvector(2));
gaussdb=#  CREATE TABLE t2 (a int, repr boolvector(2));

若定义表类型含向量维度类型,插入数据非此类型数据,则报错。

答:插入数据需要符合数据类型。
gaussdb=#  INSERT INTO t1 VALUES(0, '[10.1, 0.5]');

插入数据时,若插入向量的字符串使用格式错误,则报错。

答:插入向量的字符数据需要符合格式。
gaussdb=#  INSERT INTO t1 VALUES(1, '[1,2]');
gaussdb=#  INSERT INTO t1 VALUES(2, '{1,2}');

若定义表类型含的向量维度和插入数据不符,则报错。

答:需要插入数据的维度和设定维度一致。
gaussdb=#  INSERT INTO t1 VALUES(1, '[1,0]');
gaussdb=#  INSERT INTO t2 VALUES(0, '[T,F]');

进行不同维度数据相似性检索时报错。

答:计算相似度的向量维度需要一致。
gaussdb=#  SELECT '[2,3,1]'<-> '[1,2,3]'::floatvector AS s;

创建索引时指定错误的索引参数数值,则报错。

答:创建索引时指定范围内的参数值。
gaussdb=#  CREATE TABLE sift1m (id int unique, repr floatvector(128));
gaussdb=#  CREATE INDEX diskann_l2_idx on sift1m using gsdiskann (repr L2) WITH (pq_nseg=128, pq_nclus=16, queue_size=100, num_parallels=30, enable_pq=true, using_clustering_for_parallel=false);

创建索引时,若索引类型和属性类型不匹配,则报错。

答:索引类型和属性类型需要匹配,详细情况请参考向量索引章节。
gaussdb=#  CREATE INDEX h1 ON sift1m USING GSIVFFLAT(repr cosine) WITH (IVF_NLIST = 1024);

创建索引时,若向量维度过高,则报错。

答:高维度向量创建索引时,需启用量化压缩,并设置enable_vector_copy=false,详细情况请参见向量索引GsDiskANN章节。
gaussdb=#  CREATE TABLE sift2048 (id int unique, repr floatvector(2048));
gaussdb=#  CREATE INDEX diskann_l2_idx on sift2048 using gsdiskann (repr L2) WITH (pq_nseg=128, pq_nclus=16, queue_size=100, num_parallels=30, enable_pq=true, using_clustering_for_parallel=false, build_with_quantized_vector=true, subgraph_count=1, enable_vector_copy=false);

在线创建/在线重建索引时,若同时并发执行DDL(删表、删索引、重建索引等操作)和DML(插入、删除等操作),则可能触发死锁并报错。

gaussdb=# CREATE TABLE t1 (a int, repr floatvector(2));
gaussdb=# INSERT INTO t1 VALUES(0, '[10.1, 0.5]'); 
gaussdb=# CREATE INDEX CONCURRENTLY t1ann on t1 USING GsDiskANN(repr L2);
gaussdb=# DROP TABLE t1;
gaussdb=# UPDATE TABLE t1 set repr = '[10.2, 1.0]' where a = 0;

在线创建/在线重建索引时,若自动扩展分区表插入新数据或更新导致扩区,则报错。

gaussdb=# CREATE TABLE t1 (a int, repr floatvector(2)) partition by list(a) AUTOMATIC (partition p0 values (1));;
gaussdb=# INSERT INTO t1 VALUES(0, '[10.1, 0.5]'); 
gaussdb=# CREATE INDEX CONCURRENTLY t1ann on t1 USING GsDiskANN(repr L2);

大量删除数据后进行索引查询时,返回数据不足,小于limit的值。

答:考虑检查索引健康度,看是否需要重建索引。

gaussdb=#  SELECT * FROM gs_diskann_inspect('diskann_sift1m_l2');

在创建索引时,数组字段元素数量超过128个,则报WARNING。

答:数组字段元素数量超过128个,索引会正常创建,但不会保证性能。

gaussdb=#  CREATE TABLE test_table (id int, a bigint,repr floatvector(3), arr129 bigint[]);
gaussdb=#  INSERT INTO test_table (id, a, repr, arr129) VALUES (1,99,'{0.1,0.2,0.3}',ARRAY[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,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129]);
gaussdb=#  CREATE INDEX hybrid_idx_t0 on test_table using gsdiskann(repr L2, a, arr129) with(pq_nseg=3,pq_nclus=16,queue_size=128,num_parallels=30,subgraph_count=5);
WARNING:  Array column has more than 128 elements, which may affect performance.

在创建索引时,数组字段列超过2列,则报错。

gaussdb=#  CREATE TABLE test_table( id INT, a BIGINT, repr floatvector(16),e INT[], f BIGINT[], j SMALLINT[]);
gaussdb=#  CREATE INDEX hybrid_idx2 on test_table using gsdiskann(repr L2, id, e, f, j) with(num_parallels=30,subgraph_count=5);
ERROR:  The index contains more than two array columns, which is not allowed.

在创建向标混合索引时,指定的标量数组字段的数组维度大于1维,则报错。

gaussdb=#  CREATE TABLE t1(id int, repr floatvector(128), a int, b int, c int[][]);
gaussdb=#  CREATE INDEX hybrid_idx_t1 on t1 using gsdiskann(repr L2, a, b, c) with(pq_nseg=128,pq_nclus=16,queue_size=128,num_parallels=30,subgraph_count=5);
ERROR:  The index parameter is invalid. The following problems may occur:1.The scalar column data type is restricted.2.Only support one vector type and must be in the first column.3.To support scalar filtering, the value of subgraph_count must be greater than 0.

在创建向标混合索引时,指定的标量数组字段的元素类型为bytea类型(或其他非法类型),则报错。

gaussdb=#  CREATE TABLE t1(id int, repr floatvector(128), a int, b int, c bytea[]);
gaussdb=#  CREATE INDEX hybrid_idx_t1 on t1 using gsdiskann(repr L2, a, b, c) with(pq_nseg=128,pq_nclus=16,queue_size=128,num_parallels=30,subgraph_count=5);
ERROR:  The index parameter is invalid. The following problems may occur:1.The scalar column data type is restricted.2.Only support one vector type and must be in the first column.3.To support scalar filtering, the value of subgraph_count must be greater than 0.

当用户进行混合查询时,如果标量字段属于混合索引的标量字段集,且为数组类型,但是对数组元素使用LIKE后匹配(或其他不支持的操作符)。

答:正常执行,但是对该语句执行explain语句会发现该LIKE过滤条件不被混合索引处理。

gaussdb=#  CREATE TABLE t1(id int, repr floatvector(3), a int, b int, c varchar(128)[]);
gaussdb=#  CREATE INDEX hybrid_idx_t1 on t1 using gsdiskann(repr L2,  a, b, c) with(pq_nseg=3,pq_nclus=16,queue_size=128,num_parallels=30,subgraph_count=5);
gaussdb=#  INSERT INTO t1 (id, repr, a, b, c) VALUES (1001,'[1.1,2.2,3.3]',100,1,ARRAY['vectordb_test', 'other_value']::varchar(128)[]),
(1002, '[2.2,3.3,4.4]', 101, 1, ARRAY['vectordb_test']::varchar(128)[]), 
(1003, '[3.3,4.4,5.5]', 100, 2, ARRAY['vectordb_test']::varchar(128)[]), 
(1004, '[4.4,5.5,6.6]', 100, 1, ARRAY['other_value']::varchar(128)[]), 
(1005, '[5.5,6.6,7.7]', 101, 2, ARRAY['other_value']::varchar(128)[]), 
(1006, '[6.6,7.7,8.8]', 100, 1, ARRAY['test_value']::varchar(128)[]), 
(1007, '[7.7,8.8,9.9]', 100, 1, ARRAY['abc']::varchar(128)[]), 
(1008, '[8.8,9.9,1.1]', 100, 1, ARRAY['nobody_test']::varchar(128)[]); 
gaussdb=#  explain SELECT /*+ indexscan(t1 hybrid_idx_t1) */ id FROM t1 WHERE a=100 and b < 2 and c[1] LIKE '%vectordb%' order by repr <-> '[1,2,3]' limit 10;

用户进行混合查询时,标量数组字段使用了特定函数。

答:正常执行,但是该数组字段的过滤条件不被混合索引处理。

gaussdb=#  CREATE TABLE t1(id int, repr floatvector(3), a int, b int, c int[]);
gaussdb=#  CREATE INDEX hybrid_idx_t1 on t1 using gsdiskann(repr L2,  a, b, c) with(pq_nseg=3,pq_nclus=16,queue_size=128,num_parallels=30,subgraph_count=5);
gaussdb=#  INSERT INTO t1 (id, repr, a, b, c) VALUES (1, '[1.1, 2.2, 3.3]',100,1,ARRAY[1,2,3,4,5,6,7,8,9,10,11] ),
(2, '[2.0, 3.0, 4.0]', 99, 1, ARRAY[1,2,3,4,5,6,7,8,9,10]),  
(3, '[3.1, 4.2, 5.3]', 100, 2, ARRAY[1,2,3,4,5,6,7,8,9,10,11]), 
(4, '[4.0, 5.0, 6.0]', 100, 1, ARRAY[1,2,3,4,5,6,7,8,9,10]),   
(5, '[5.5, 6.6, 7.7]', 101, 0, ARRAY[1,2,3,4,5,6,7,8,9,10,11,12]), 
(6, '[6.1, 7.2, 8.3]', 100, 3, ARRAY[1,2,3,4,5,6,7,8,9,10,11,12]), 
(7, '[7.7, 8.8, 9.9]', 100, 1, ARRAY[1,2,3,4,5,6,7,8,9,10]), 
(8, '[8.0, 9.0, 10.0]', 101, 1, ARRAY[1,2,3,4,5,6,7,8,9,10,11,12,13]);
gaussdb=#  explain SELECT /*+ indexscan(t1 hybrid_idx_t1) */ id FROM t1 WHERE a=100 and b < 2 and array_length(c, 1) > 10 order by repr <-> '[1,2,3]' limit 10;

在创建向标混合索引时,CHAR和VARCHAR参数大于256,则报错。

gaussdb=#  CREATE TABLE t1(id int, repr floatvector(128), col varchar(257)[10]);
gaussdb=#  CREATE INDEX hybrid_idx_t1 on t1 using gsdiskann(repr L2, col) with(subgraph_count=5);
ERROR:  The VARCHAR column exceeds the maximum allowed length of 256 characters.

分区表在执行文档相似性查询时,如果存在任意分区是不可用的,则报错。

gaussdb=# ALTER INDEX test_bm25idx MODIFY PARTITION p1 UNUSABLE;
ALTER INDEX
gaussdb=# SELECT /*+ indexscan(test test_bm25idx) */id, text, text ### '客户' as relevance_score FROM test ORDER BY relevance_score DESC LIMIT 10;
ERROR:  Some partitions' indexes are unusable, this is not currently supported.

相关文档