Postgres-独特的查询速度超过500万个数据

问题描述 投票:0回答:1

我正在尝试对具有500万个数据的表进行不同的选择,这大约需要2分钟。我的目的是将速度提高到几秒钟。 enter image description here

查询:-从t_fin_do中选择不同的帐户类型,其中country_id ='abc'

postgresql distinct
1个回答
0
投票

您可以尝试使用以下方法为此查询创建部分覆盖索引:

 create index on t_fin_do(country_id, accounttype) where country_id='abc';

取决于country_id的选择性,可能比表顺序扫描更快。

© www.soinside.com 2019 - 2024. All rights reserved.