• 先取主键最大值再取extracted_time,替换Max(extracted_time)会有更高的效率


    ---说明:在表article_detail中,article_detail_id是主键,extracted_time默认是sysdate,且建了索引,下面二条语句的查询结果相同,第二条的执行效率高些

    --1.各网站最后一条记录入库时间(效率低)
    select website_no, max(extracted_time) as Last_extracted_time from article_detail where 
    website_no 
    in 
    (
    'FM37','FM38','FM39','FM41','FM42','FM43','FM44','FM45','FM46',
    'FM48','FM49','FM50','FM51','FM52','FM107','FM108','FM109','FM110','FM111','FM112','FM121',
    'NW35','NW36','NW37','NW38','NW39','NW40','NW41','NW42','NW43',
    'BG9','BG10','BG11','BG12'
     )
    group by website_no order by website_no;


    --2.各网站最后一条记录入库时间(效率较高)
    select website_no,extracted_time as Last_extracted_time from article_detail where article_detail_id in
    (
       
    select max(article_detail_id) as article_detail_id from article_detail where 
       website_no 
    in ('FM37','FM38','FM39','FM41','FM42','FM43','FM44','FM45','FM46',
       
    'FM48','FM49','FM50','FM51','FM52','FM107','FM108','FM109','FM110','FM111','FM112','FM121',
       
    'NW35','NW36','NW37','NW38','NW39','NW40','NW41','NW42','NW43',
       
    'BG9','BG10','BG11','BG12'
       )
    group by website_no
    )
    order by website_no;
  • 相关阅读:
    NSURLSession学习笔记(二)Session Task
    NSURLSession学习笔记(一)简介
    iOS Core Animation 简明系列教程
    iOS夯实:RunLoop
    mysql主从复制读写分离
    git文件名大小写问题
    mysql zip 安装
    maven dependencies与dependencyManagement的区别
    Eclipse使用技巧
    相关开发软件http代理设置 windows
  • 原文地址:https://www.cnblogs.com/krisy/p/1645028.html
Copyright © 2020-2023  润新知