我下面的SQL查询一直很好,直到thirdparty_token_airdrops最终有20万行,thirdparty_token_holders有90万行。在这种规模下,优化它的最佳方式是什么?
select id, owner
from thirdparty_token_holders
where id not in (
select holder_id
from thirdparty_token_airdrops
where status=1
)
and amount > 10000000000
limit 300
在索引方面,我创建了以下内容:
CREATE UNIQUE INDEX holder_id on thirdparty_token_airdrops (id, holder_id);
CREATE UNIQUE INDEX owner_address on thirdparty_token_holders (owner, address);
CREATE UNIQUE INDEX owner_id on thirdparty_token_holders (owner, id);