« first day (2479 days earlier)      last day (2403 days later) » 
00:00 - 23:0023:00 - 00:00

11:00 PM
:O
 
Everything's a duplicate of something I've answered. I'm surprised it's taking you all so long to catch on to that.
In fact your rep is a duplicate of mine.
Please post it over.
 
31 mins ago, by sp_BlitzErik
get the aloe
 
Lemonade apple flavo(u)red popcorn all round
 
tonight I'm going to feast on row goals
 
@JoeObbish *crow goals
 
11:06 PM
ok
I think I reverse engineered the cost reduction applied to a scan of a heap by a row goal
for the simple case of SELECT TOP (N) * FROM HEAP WHERE ...
I'm sure that Paul figured this out 10 years ago
now I need to figure out the harder part
 
what about when there are forwarded records or empty pages?
 
good question
I don't think it should matter
@sp_BlitzErik empty pages don't appear to matter, just tested
too lazy for forwarded records, but I don't see why it would matter
I believe the only inputs are cost of typical full scan, the row goal, and the CE
 
but both might mean that the reduction is wrong
heh
 
hmm
does updating stats clear out empty pages?
but yeah, there are all kinds of problems
I'm hoping that I can put together a document to convince MS to change how it works
rate my chances out of 10
 
Joe Chang tried that for years
 
11:20 PM
row goals specifically?
 
Costing formulas in general. TOP was a part of it.
 
I've never noticed anything as broken as TOP
 
Can you be less specific?
 
yes
 
Never mind I'll just wait for the blog post
 
11:22 PM
it's all about what's going on in this answer: dba.stackexchange.com/questions/188704/…
 
Yeah I assumed that much
 
the first query plan is ridiculous
for the query to return 500 rows it must do 500 "full scans" of EVEN
right?
 
Of course Paul is correct - it is picking what appears to be cheaper. I think the question here is why is the optimizer think the index is more expensive than full table scan to get single row from > 8 million rows and why when it uses the index (by forcing through a hint) does it use it incorrectly in 2016 (which accounts for the high cost)? — Saxman 1 min ago
Who does he think answered?
 
@sp_BlitzErik I had to
 
Heh heh heh
Great post, Paul!©
 
11:27 PM
can I upvote the post but make it go to Paul?
@PaulWhite Let me know if I'm being ambiguous. Not trying to make you guess
 
It should anyway, it's a duplicate of his whole career
 
@JoeObbish Just clearing the decks a bit so I can give you a larger fraction of my attention
Please stand by
 
I will await your fax that explains it all
joins really are the worst
so hard to get cardinality estimates
we should just stop doing joins
think about how much easier query optimization would be
 
Have you heard of NoSQL?
 
11:35 PM
@PaulWhite I hope when you die I'm alive, rich, and eccentric enough to keep your brain in a jar.
 
think I've seen that one
it matches the formula that I found for costing
but still doesn't answer the fundamental question
 
@JoeObbish The issue I'm drawing your attention to is the introduction of a group by and the GbAggToConstScanOrTop transform.
That's the one I have an issue with.
In that specific scenario.
w.r.t row goals
I'm certain I've written about this before, but it's not springing to mind.
I thought I had a Connect item about it.
 
I think I got the formula right when the outer table has 2 rows!
it's the same scenario as my question, right?
it might be worth digging into the optimizer rules in what I send off
 
Yes that's why it reminded me
 
that's going to save me a lot of work if I do
 
11:45 PM
LASJNtoLASJNonDist and LASJOnLclDist
 
although this formula doesn't make sense either
so let's say you cross join to a heap twice
estimated cost of a scan of the heap without a row goal is going to be IO + 2 * CPU
I presume because the optimizer assumes that it's in the cache for the second scan, right?
 
As I recall there's a somewhat complex adjustment for the chance of the same pages being in cache after the first time.
 
oh
well it's trivial in this case, for whatever reason
anyway
 
But anyway, and as a side issue, consider the effect of QUERYTRACEON 9114 on your odd/even demo.
 
I add a row goal
I pay 1/3 of the IO cost for the first scan
I pay 0 of the IO cost for the second scan
it makes no sense
spools are no fun
 
11:51 PM
It's the difference between an apply and a naive nested loop
 
it's a good trick to be sure (and I might be missing the point), but I'm already buried pretty deep here
I think you used this one before
yes, you did
ok, I got a reasonable model for when the optimizer uses density to calculate the join CE
I think
 
@JoeObbish I'm afraid the detail of cost numbers never interested me very much. Joe Chang did some good work in this area back in the day qdpma.com/cbo/SQLServerCostBasedOptimizer.html not sure how relevant that is to you, but you might find it interesting.
I do have an issue with the choice between apply/naive nested loop and the introduction of a row goal from the group by/top transform on the inner side of a LASJ, in general.
It does cause real problems, how ever one might criticize the simple demos.
 
I'm seeing it on columnstore
(in production)
 
And the uniform distribution assumption is certainly problematic in general.
 
yeah I've seen his stuff and it's answered a few random questions that I've had, but I can't find the time to really read it
 
11:58 PM
Time is always the problem.
 
I'm trying to make as strong of an argument as I can here
if I can almost figure out how it currently works that should help
 
But you choose not to enable 4138 globally?
 
do people actually do that? it seems a bit extreme...
 
Precisely
 
how should I put it
I'd like to turn TF 4138 half on
does that make sense?
 
11:59 PM
Of course
OTOH: Much of the time, it does what is needed. On the occasions it doesn't, we have humans.
 
00:00 - 23:0023:00 - 00:00

« first day (2479 days earlier)      last day (2403 days later) »