我有一个包含 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)