简体   繁体   English

RDS实例CPU为99%

[英]The RDS instance CPU is 99%

Query taking a long time to execute in AWS RDS需要很长时间才能在 AWS RDS 中执行的查询

The one query is taking too much time around 3 minutes.一个查询花费了大约 3 分钟的时间。 Db is hosted in AWS RDS with 2cpu and 4GB ram (t2. medium)数据库托管在具有 2cpu 和 4GB 内存(t2.medium)的 AWS RDS 中

The Query Sample is查询样本是

select  DATE_FORMAT(log_date, '%d-%m-%Y') as 'Day',
        sum(people_count) as 'count'"
    from  avg_people_pass
    where  log_date >= #startDate
      and  log_date <= #endDate 

appreciate your help because it lagging all the solution.感谢您的帮助,因为它落后于所有解决方案。

select DATE_FORMAT(log_date, '%d-%m-%Y') as 'Day',sum(people_count) as 'count' from avg_people_pass where log_date >= #startDate and log_date <= #endDate

I'm guessing you have no indexes configured on this table and that as a result you're doing a full table scan.我猜您没有在此表上配置索引,因此您正在进行全表扫描。 3 minute execution time implies a woefully designed, large table with no indexing, keys or optimization. 3 分钟的执行时间意味着一个设计糟糕的大表,没有索引、键或优化。

What happens when you run跑步时会发生什么

explain select DATE_FORMAT(log_date, '%d-%m-%Y') as 'Day',sum(people_count) as 'count' from avg_people_pass where log_date >= #startDate and log_date <= #endDate

A query plan will help narrow down the performance issues.查询计划将有助于缩小性能问题的范围。

This should make it run as fast as it's ever going to, assuming you don't already have an index on this column:这应该使它运行得像以往一样快,假设您还没有在此列上的索引:

CREATE INDEX idx1 ON avg_people_pass (log_date);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM