yunxiaoxiao

sqlserver 查询缓慢问题

  •  1
     
  •   yunxiaoxiao · Mar 28, 2023 · 3094 views
    This topic created in 1164 days ago, the information mentioned may be changed or developed.

    请教懂 sqlserver 数据库的大神,帮忙看看我一个 sql 语句查询缓慢的问题:

    语句 1:select * from table1 where optime>='2023-03-01' and optime<='2023-03-28',表里有 5000 万数据,optime 字段做有索引,查询在 1 秒之内就出结果了。

    语句 2: select count(1) from (select * from table1 where optime>='2023-03-01' and optime<='2023-03-28') a ,查询非常缓慢,基本都是超时。感觉 optime 索引没用一样。

    请帮忙看看怎么改进。谢谢

    F281M6Dh8DXpD1g2
        1
    F281M6Dh8DXpD1g2  
       Mar 28, 2023
    看执行计划,大概率 sql server 没选到索引
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1304 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 23:49 · PVG 07:49 · LAX 16:49 · JFK 19:49
    ♥ Do have faith in what you're doing.