Skip to content

vector index on clutstered non-int pk table might output empty result #57627

@winoros

Description

@winoros

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE `chunks_1_backup` (
  `id` char(32) NOT NULL,
  `hash` varchar(64) NOT NULL,
  `text` text DEFAULT NULL,
  `meta` json DEFAULT NULL,
  `embedding` vector(1536) DEFAULT NULL COMMENT 'hnsw(distance=cosine)',
  `document_id` int DEFAULT NULL,
  `relations` json DEFAULT NULL,
  `source_uri` varchar(512) DEFAULT NULL,
  `index_status` enum('NOT_STARTED','PENDING','RUNNING','COMPLETED','FAILED') NOT NULL,
  `index_result` text DEFAULT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
  KEY `fk_1` (`document_id`),
  KEY `ix_chunks_1_id` (`id`),
  VECTOR INDEX `vec_idx_embedding`((VEC_COSINE_DISTANCE(`embedding`)))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin

Insert some data.

Run SQL like select ... from chunks_1_backup order by VEC_COSINE_DISTANCE(embedding, const) limit 10

2. What did you expect to see? (Required)

Should output valid result.

3. What did you see instead (Required)

empty result.

4. What is your TiDB version? (Required)

current master

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions