• 查询sql limit用法,望大神指教


    mysql 中使用了连接查询,但是使用 limit 后查询时间反而更长了,没弄明白什么原因,sql 如下

    SELECT
        `t`.*
    FROM
        `order_main` `t`
    LEFT JOIN `base_supplier` `c` ON `t`.`OUTSIDE_SALE_ORG_ID` = `c`.`ID`
    LEFT JOIN `dict_type` ON `t`.`ORDER_STATUS` = `dict_type`.`ID`
    LEFT JOIN `base_user` ON `t`.`CREATE_USER_ID` = `base_user`.`ID`
    LEFT JOIN `base_user` `m` ON `t`.`SALES_MAN` = `m`.`ID`
    LEFT JOIN `order_ht_status_log` ON `t`.`ORDER_ID` = `order_ht_status_log`.`ORDER_ID`
    LEFT JOIN `base_user` `lu` ON `order_ht_status_log`.`CREATE_USER_ID` = `lu`.`ID`
    WHERE
    `order_prod_type` = 25 AND `t`.`cancel_flag` = 0 AND `ORDER_VALID_STATUS` = 1 AND `t`.`DOCKING_TYPE` = 556
     AND `order_ht_status_log`.`ORDER_STATUS` = 198 AND `order_ht_status_log`.`BEFORE_STATUS` = 313
    AND `t`.`CREATE_TIME` BETWEEN '2018-03-01 00:00:00' AND '2018-03-08 23:59:59'
    GROUP BY
        `t`.`ORDER_ID`

    如果添加 limit 条件执行时间是当前sql的70~80倍,不知道什么原因,求大神解惑

  • 相关阅读:
    shell数组(产生不同的随机数)
    统计服务连接状况
    子网掩码与子网划分
    oracle 12g sqlplus安装
    MySQL的备份和还原
    mysql日志
    mysql用户和权限管理
    mysql show
    CentOS Linux解决Device eth0 does not seem to be present
    mysqldump命令详解(转载)
  • 原文地址:https://www.cnblogs.com/wanglg629/p/8530637.html
Copyright © 2020-2023  润新知