~/talk

Beware of nondeterministic T-SQL code

Talkat SQLBits 2022 · 2022-03-08..03-12· [databases]
links:none on file
slides:none on file

Shows concrete failures and fixes: pagination with OFFSET ... FETCH or TOP returns nonrepeatable rows when ORDER BY isn’t a strict total order, because the optimizer chooses different plans; solution is to add a tiebreaker (e.g., OrderID) or use TOP ... WITH TIES semantics. Demonstrates using a CTE to separate filter ordering from presentation ordering, explains when to use ROW_NUMBER vs RANK/DENSE_RANK, and how a running total needs RANGE (not ROWS) to emulate WITH TIES. Ends with a constant-folding trick to force a non-sorting plan.

AI-written summary · about

  1. 0:00Introduction to the session
  2. 1:14Understanding determinism
  3. 4:21Pagination and ordering issues
  4. 6:47Offset fetch design
  5. 9:30Fixing non-deterministic pagination
  6. 16:31Handling ties in top filters
  7. 21:23Separating filtering and presentation
  8. 27:02Window functions and ranking
  9. 35:12Running totals and scope
  10. 45:46Advanced non-deterministic tricks
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.