[英]Postgres query on very large table with indexes still very slow
The following query is running very slowly despite mytable being indexed on recdate
(mytable has > 60 M records) query takes almost 7 minutes. 尽管mytable在
recdate
上被索引(mytable具有> 60 M记录),但以下查询的运行非常缓慢,查询几乎花费了7分钟。
select to_char(recdate, 'yyyy'), count(*)
from mytable
group by to_char(recdate, 'yyyy')
You didn't provide execution plan, but I guess function-based index would cover 您没有提供执行计划,但我想基于函数的索引将涵盖
CREATE INDEX mytable_idx ON mytable( to_char(recdate,'yyyy'));
query: 查询:
select to_char(recdate,'yyyy'),count(*)
from mytable
group by to_char(recdate,'yyyy')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.