The following query is running very slowly despite mytable being indexed on recdate
(mytable has > 60 M records) query takes almost 7 minutes.
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')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.