Fastest way to find which hours have 0 rows in a table with a month’s data?
I have a Very Large/slow table (35gb data, 70gb indexes) on an Azure SQL MI that’s roughly this:
SQL Scan vs Seek when using OR in where criteria
Consider the following two queries from the AdventureWorks database. The where criteria is entirely on a primary key column. If you use OR criteria both tables get a full table scan on them. In the second scenario the criteria is split out over two queries that are unioned. In the second scenario both tables get index seeks. Can someone explain why SQL can’t/won’t optimize the first query to do in index seek? Are there ways to tell SQL to do a seek without rewriting as a UNION? (I’ve tried index hints with no success)