当前位置:网站首页>MySQL comparison

MySQL comparison

2022-06-11 10:12:00 Yu 1990

sql Optimize :https://www.cnblogs.com/lonnie/p/8320095.html

1、 When the database counts the data of a day, but the database fields are stored datatime When it comes to type ( Of course, it is better to use it directly data The date type )

where Use... In sentences data_format and like The time difference ( The principle is better in where It is better not to have function calculation on the right side of the statement, and also not to use like This will cause traversal of the entire table   ) When you really want to use it     The same watch   data 5855603 When you have data

select * from dobi_core.t6027
where F06 like '2019-08-31%'

Execute multiple times, usually in 8s about

select * from dobi_core.t6027
where date_format( F06 ,'%Y-%m-%d') = '2019-08-31'

And when using calculation, it usually needs 9.5s about    

select * from dobi_core.t6027 where F06 >= '2019-08-31 00:00:00' and F06 < '2019-09-01 00:00:00'

Execution of the above takes time, usually in 8.5s about

When using date statistics , Finally, use the above method

 

 

原网站

版权声明
本文为[Yu 1990]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206110928059939.html