如果Postgresql Cube Gist Index工作正常

时间:2017-09-30 15:58:29

标签: postgresql postgresql-9.6

我试图弄清楚我的表格的立方体列上的GIST索引是否适用于我最近邻居的查询(metric = Euclidean)。我的立方体值是75维向量。

表:

\d+ reduced_features
                   Table "public.reduced_features"
  Column  |  Type  | Modifiers | Storage | Stats target | Description
----------+--------+-----------+---------+--------------+-------------
 id       | bigint | not null  | plain   |              |
 features | cube   | not null  | plain   |              |
Indexes:
    "reduced_features_id_idx" UNIQUE, btree (id)
    "reduced_features_features_idx" gist (features)

这是我的问题:

explain analyze select id from reduced_features order by features  <-> (select features from reduced_features where id = 198990) limit 10;

结果:

QUERY PLAN
---------------
 Limit  (cost=8.58..18.53 rows=10 width=16) (actual time=0.821..35.987 rows=10 loops=1)
   InitPlan 1 (returns $0)
     ->  Index Scan using reduced_features_id_idx on reduced_features reduced_features_1  (cost=0.29..8.31 rows=1 width=608) (actual time=0.014..0.015 rows=1 loops=1)
           Index Cond: (id = 198990)
   ->  Index Scan using reduced_features_features_idx on reduced_features  (cost=0.28..36482.06 rows=36689 width=16) (actual time=0.819..35.984 rows=10 loops=1)
         Order By: (features <-> $0)
 Planning time: 0.117 ms
 Execution time: 36.232 ms

我的表中有36689条记录。我的索引有效吗?

0 个答案:

没有答案