PostgreSQL视图按分组返回非常慢的结果

时间:2020-01-05 17:07:07

标签: postgresql postgresql-9.4 postgresql-9.5

我有10个表具有相同的列。我按年度分别制作了数据,如2011,2012 .. 2020

我制作了一个视图,用于使用union all合并所有表数据。

    create view as a combine
    select * from table_2011
    union all
    select * from table_2012
    ..
    union all 
    select * from table_2020;

现在,当我运行一些以9分钟为单位进行分组的查询以返回数据时。

    select name, count(name) from combine group by name;

谁能帮助我提高观看速度?我已经为所有表和列都提供了索引。

analysed select

1 个答案:

答案 0 :(得分:0)

在视图的名称列中添加索引

相关问题