zoukankan      html  css  js  c++  java
  • SQL 统计某一天的数据量时, 使用 dateValue(字段) 与 between 性能差异很明显。

    感觉好久没有写sql语句了...

    今天需要写一个统计某一天的数据时,考虑到字段的内容格式是:  2018-12-18 09:36:23

    我开始写的是:

    select count(id) as reCount from t1 where dateValue(atTime)=" & sqlDate(theDate)

    数据量在1万行记录的时候,尽然需要 3 秒+时间才能完成。

    等所有代码完工后,我试着使用 Between  语句:

    select count(id) as reCount from t1 where atTime Between " & sqlDate(theDate) & " and " & sqlDate(theDate & " 23:59:59") 

    sql语句执行的时间感觉不到 1 秒,0.5 秒左右就完工了。

    结论:

    我一开始使用 dateValue(字段) 是错误的,这个不科学,太耗时了。

    改成 between 后,速度提升很明显。

  • 相关阅读:
    我的vimrc设置
    nginx
    选中
    vscode垂直选中列选中
    lsof
    bashrc和bash_profile
    centos安装tree命令
    linux查看磁盘大小df命令
    linux查看文件夹大小du命令
    git本地推送远程
  • 原文地址:https://www.cnblogs.com/personnel/p/10136642.html
Copyright © 2011-2022 走看看