Fastest way for this query (What is the best strategy) given a date range

前端 未结 10 2395
半阙折子戏
半阙折子戏 2021-01-02 11:35

I have a table A that has a startDate and an end dateDate as 2 datetime columns besides some more other columns. I have another table B that has one datetime column call it

10条回答
  •  既然无缘
    2021-01-02 12:23

    I would just add a clustered index on B.dates. If you add indexes on startDate and endDate it won't buy anything because you'll get index scans on A anyway. The clustered index on B gets you an index seek in B at least. A Table Scan and Index Scan are the same thing so there's no point in adding indexes to get the word Table Scan out of your execution plan :)

    I'd mock it up a few ways or see if you can redo your query to not require a table scan on A which I'm guessing isn't really possible.

提交回复
热议问题