小编reo*_*eox的帖子

使用 GROUP BY 和 ORDER BY 对大表进行慢速查询

我有一个包含 720 万个元组的表,如下所示:

                               table public.methods
 column |          type         |                      attributes
--------+-----------------------+----------------------------------------------------
 id     | integer               | not null DEFAULT nextval('methodkey'::regclass)
 hash   | character varying(32) | not null
 string | character varying     | not null
 method | character varying     | not null
 file   | character varying     | not null
 type   | character varying     | not null
Indexes:
    "methods_pkey" PRIMARY KEY, btree (id)
    "methodhash" btree (hash)
Run Code Online (Sandbox Code Playgroud)

现在我想选择一些值,但查询速度非常慢:

db=# explain 
    select hash, string, count(method) 
    from methods 
    where hash not in 
          (select hash from nostring) …
Run Code Online (Sandbox Code Playgroud)

postgresql performance index sorting group-by

14
推荐指数
2
解决办法
3万
查看次数

标签 统计

group-by ×1

index ×1

performance ×1

postgresql ×1

sorting ×1