Skip to main content

New answers tagged

2 votes

Hash join hint returns an error when using local variable

Your query: DECLARE @Id INT = 18471 SELECT c.UserId FROM dbo.Comments AS c INNER HASH JOIN dbo.Users AS u ON c.UserId = u.Id AND c.UserId = @Id has c.UserId = u.Id and AND c.UserId = @Id. By ...
Paul White's user avatar
  • 88.3k
-1 votes
Accepted

Unstable plans when two first index columns have NULL values in all rows

I hate to approve my own answers, but this time I think I got it right. After 3 days of tinkering with this issue I came to the conclusion that SQL Server gets lost with single-step statistics. After ...
Endrju's user avatar
  • 204
3 votes

Unstable plans when two first index columns have NULL values in all rows

You can create a partial index with only the NOT NULL values: create index ix_test on t1 (c2, c3, c4, ID) where c2 is not null and c3 is not null; This index will be extremely small (and fast) and ...
Andrea B.'s user avatar
  • 1,653
8 votes

Unstable plans when two first index columns have NULL values in all rows

-- When you check the stats histogram, there's none. That's a bug in sys.dm_db_stats_histogram. DBCC SHOW_STATISTICS shows the NULL row correctly (this is what SSMS uses). The original problem with ...
Paul White's user avatar
  • 88.3k
1 vote

Inconsistent query planners between two Postgres 16.4 instances

I can't read Dalibo's plan obfuscator, but in the raw output we can see the difference. Slow: -> Index Scan using stations_pkey on stations s (cost=0.28..177.61 rows=14 width=347) (actual time=...
Laurenz Albe's user avatar
  • 54.8k
1 vote

Sqlite fetching speed problem - how to understand explain and compare two queries

I would like to understand the different query plans and how to measure the execution speed and also the "math" reason why one query is faster then the other. Also what am i doing wrong? I ...
White Owl's user avatar
  • 939

Top 50 recent answers are included