📣
TiDB Cloud Premium 开放公测中。为企业级工作负载提供无限扩展、即时弹性伸缩和高级安全保障。此页面由 AI 自动翻译,英文原文请见此处。

REFRESH SPATIAL INDEX



TiDB Cloud Lake 会在 SYNC 模式下每次写入新数据时自动刷新空间索引。REFRESH SPATIAL INDEX 主要用于回填在声明索引之前已存在的行。

语法

REFRESH SPATIAL INDEX <index> ON [<database>.]<table> [LIMIT <limit>]
参数描述
<limit>指定刷新索引期间要处理的最大行数。如果未指定,则会处理表中的所有行。

示例

-- Existing table with data loaded before the index was declared CREATE TABLE IF NOT EXISTS stores ( store_id INT, location GEOMETRY ) ENGINE = FUSE; INSERT INTO stores VALUES (1, TO_GEOMETRY('POINT(10 10)')), (2, TO_GEOMETRY('POINT(20 20)')); -- Create the spatial index afterward CREATE SPATIAL INDEX stores_location_idx ON stores(location); -- Backfill historical rows so the index covers earlier inserts REFRESH SPATIAL INDEX stores_location_idx ON stores; -- Future inserts refresh automatically in SYNC mode

文档内容是否有帮助?