Categories
SQL Server

Simpler Date Patterns in SQL Server

Date handling in SQL Server tends to accumulate tried and trusted combinations of DATEPART(), DATEADD(), and DATEDIFF() – with nested variations. The challenge with these isn’t raw performance, but more with conveying intent and readability. So let’s look at some simpler patterns to try and avoid some of these and be clearer with what we’re […]

Categories
T-SQL Tuesday

T-SQL Tuesday #200 – It’s Bad If I See…

For the bicentennial edition of T-SQL Tuesday, Brent has thrown down the topic of “When I’m looking at a query, I bet it’s bad if I see ____.”. I’m expecting the Brits out in force for this game of Blankety Blank. There are some things which terrify me when troubleshooting: Not necessarily in that order. But there’s […]

Categories
SQL

Blazing Fast (and Accurate) Searches Without an Index

Last week I demonstrated a fast binary search approach to quickly slice through large unindexed tables. I love the approach, but it fell short in two key areas – drop-in usage, and proper boundary handling. Why Let’s recap what we’re doing here: Large append-heavy tables – like logs or audits – often don’t have a useful index […]

Categories
SQL

Blazing Fast Searches Without an Index

I know, clickbait right? Hear me out. Searching vast log or audit tables without indexes is painful. Narrowing down a specific time range often means scanning millions or billions of rows. But that doesn’t have to be the case. Approach This approach is designed for tables with two particular characteristics: The combination of these characteristics […]