跳转至
开发版采用单机部署,无需产品 License 文件。需要多机部署或大规模性能测试? 了解企业版

SHOW (ALL) INDEXES

SHOW ALL INDEXES命令返回当前会话的 Schema 下的所有索引的信息。

SHOW INDEXES命令返回特定图或临时图的索引的信息。

可选择以下任意方法来指定图或临时图:

  • 在本命令前添加 USE 子句来设定工作图。
  • 提前使用 SESSION SET 设置当前会话的图或临时图。

若两种方法均使用,则以 USE 子句中的指定为准。若均未使用,则报错。

对于持久化对象,当前用户必须拥有父级 Schema 的USAGE。该要求不适用于临时图。更多信息,请参见 Schema 访问控制。

Note

该命令仅返回用户创建的索引信息,不返回系统创建的索引信息。

下表展示了返回的信息:

列 描述
name 索引的名称。
state 索引的状态。取值:Valid(有效)和Building(构建中)。
index_type 索引的类型。取值:Normal(普通索引)、Vector(向量索引)、Spatial(空间索引)和Fulltext(全文索引)。
对于向量索引,还会返回相似性度量、维度数等细节。更多信息,请参见 CREATE VECTOR INDEX。
对于空间索引,还会返回网格最大层级和最多覆盖单元数等细节。更多信息,请参见 CREATE SPATIAL INDEX。
schema 索引所属的 Schema 的路径。
graph_name 索引所属的图或临时图的名称。
entity_type 创建索引的图元素类型。取值:NODE和EDGE。
element_type 创建索引的图元素的名称。
properties 创建索引所依赖的属性列表。

语法

show_all_indexes_command
SHOW ALL INDEXES
show_indexes_command
SHOW INDEXES

show_all_indexes_command ::=
    'SHOW' 'ALL' 'INDEXES'

show_indexes_command ::=
    'SHOW' 'INDEXES'

示例

以下示例基于示例数据集。有关如何创建不同类型的索引,请参见索引概述。

显示特定图上的索引

USE movie SHOW INDEXES

返回:

+------------------+-------+------------+-----------------+------------+-------------+--------------+-------------------+
| name             | state | index_type | schema          | graph_name | entity_type | element_type | properties        |
+------------------+-------+------------+-----------------+------------+-------------+--------------+-------------------+
| idx_actor_age    | Valid | Normal     | /default_schema | movie      | Node        | Actor        | ["birthDate ASC"] |
| idx_watch_rating | Valid | Normal     | /default_schema | movie      | Edge        | Watch        | ["rate DESC"]     |
+------------------+-------+------------+-----------------+------------+-------------+--------------+-------------------+

显示特定临时图上的索引

USE #movie_temporary_graph SHOW INDEXES

返回:

+-----------------------+-------+------------+-------------+------------------------+-------------+--------------+-------------------+
| name                  | state | index_type | schema      | graph_name             | entity_type | element_type | properties        |
+-----------------------+-------+------------+-------------+------------------------+-------------+--------------+-------------------+
| idx_actor_age_temp    | Valid | Normal     | /tmp_schema | #movie_temporary_graph | Node        | Actor        | ["birthDate ASC"] |
| idx_watch_rating_temp | Valid | Normal     | /tmp_schema | #movie_temporary_graph | Edge        | Watch        | ["rate DESC"]     |
+-----------------------+-------+------------+-------------+------------------------+-------------+--------------+-------------------+

显示当前 Schema 中的所有索引

SHOW ALL INDEXES

返回:

+-----------------------+-------+------------------------------------------------------------------------+-----------------+------------------------+-------------+--------------+-------------------+
| name                  | state | index_type                                                             | schema          | graph_name             | entity_type | element_type | properties        |
+-----------------------+-------+------------------------------------------------------------------------+-----------------+------------------------+-------------+--------------+-------------------+
| idx_actor_age         | Valid | Normal                                                                 | /default_schema | movie                  | Node        | Actor        | ["birthDate ASC"] |
| ft_movie              | Valid | Fulltext                                                               | /default_schema | movie                  | Node        | Movie        | [name]            |
| idx_watch_rating      | Valid | Normal                                                                 | /default_schema | movie                  | Edge        | Watch        | ["rate DESC"]     |
| idx_gnode_g           | Valid | Spatial(max_level=30, max_cells=8)                                     | /default_schema | my_graph               | Node        | Person       | [any_geo]         |
| idx_node_vec1         | Valid | Vector{type:IVF, metric:L2, dimension:3, nlist:10, trainSize:4}        | /default_schema | ann_test_graph         | Node        | N1           | [vec1]            |
| idx_actor_age_temp    | Valid | Normal                                                                 | /default_schema | #movie_temporary_graph | Node        | Actor        | ["birthDate ASC"] |
| idx_watch_rating_temp | Valid | Normal                                                                 | /default_schema | #movie_temporary_graph | Edge        | Watch        | ["rate DESC"]     |
+-----------------------+-------+------------------------------------------------------------------------+-----------------+------------------------+-------------+--------------+-------------------+