« first day (2509 days earlier)      last day (2359 days later) » 
00:00 - 03:0003:00 - 00:00

3:00 AM
still don't get it
can't it just be sneaky and read the partitions in the correct order?
it just so happens that the order is what we expect in the examples
look at the first sort example
if part 1 was 07/01, part 2 was 09/01, and part 3 was 08/01
it seems as if the storage engine could certainly do a clustered index scan that reads 1, 3, then 2
 
let's find out
you lazy mong
 
@sp_BlitzErik I don't know how to get them out of order, do you?
 
no, but i'll try
 
there's a section on hex editing at bits
go to that and report back
@sp_BlitzErik FINE I'LL TRY TOO
 
> Warning: Range value list for partition function 'YourMom' is not sorted by value. Mapping of partitions to filegroups during CREATE PARTITION SCHEME will use the sorted boundary values if the function 'YourMom' is referenced in CREATE PARTITION SCHEME.
CREATE PARTITION FUNCTION YourMom ( INT )
    AS RANGE LEFT FOR VALUES ( 5, 3, 1, 4, 2 );
 
3:06 AM
that's all you had to do?
 
not sure it did anything in the end
what a lucky function id, eh?
 
you sure create a lot of functions
 
all named yourmom
 
ok
I got a SERVER LEVEL performance question
are you ready?
 
i am a professional
3
 
3:12 AM
let's say I got 8 CPUs
wait
I'll just test it
nevermind
 
one of these days, obbish
2
 
you just called me a "lazy mong"
shouldn't I make an effort before asking a question?
I don't want to be one of those people
 
cat's out of the bag
 
Ooo! Hang on I've got one that'll really tease your brain cells!
Stop what you're doing and pay attention because this is awesome
 
did adam ask you about writing a weird function too?
 
3:14 AM
Grab any nearby friends and point them at your screen
wait
I'll just test it
nevermind
:-D
 
@sp_BlitzErik you want to rate my CPU burning function that I just wrote?
 
yes?
 
oh, I forgot to say it isn't a function
does that change the answer?
 
heh
 
as long as it functions
 
3:21 AM
funny story, it just errored out
need to fix it
ok, so here's the question (and the answer)
I got four CPUs
I rig things so that schedule 3 is very busy
have it at 4X capacity
intuitively, I would expect a MAXDOP 3 query to perform better than a MAXDOP 4 query
MAXDOP 4: CPU time = 1735 ms, elapsed time = 3674 ms.
MAXDOP 3: CPU time = 1797 ms, elapsed time = 637 ms.
important detail that I forgot: I made sure the query had round robin partitioning
I know that SQL Server can downgrade DOP, but as far as I know that's pretty rare
does anyone have a slick demo of that? maybe I could make one eventually
 
"intuitively"
 
did I spell that wrong?
I didn't
what's wrong with that
 
i just have no idea why that would be intuitive
 
4 schedulers, round robin partition forces equal work to all involved schedulers, MAXDOP 3 means I can get the three free schedulers, MAXDOP 4 means a thread must be assigned to the overloaded one
 
right, but scheduling is cooperative
 
3:27 AM
what do you mean by that?
 
even on a busy core, quantums are exhuasted and other tasks are given time
there are some trace flags there you could maybe use to prove out your theory
fraudulently
 
I know that the stuff is really complicated
but there are only four schedulers
scheduler 3 is at 4X capacity
so very naive assumption, but if I run another query on scheduler 3, I'll get 20% of the quantums
right?
 
i believe it depends on if the other tasks are waiting on <something else>
 
wait time for SOS_SCHEDULER_YIELD = 2456 ms
total elapsed time for query = 3674 ms
(3674 - 2456) / 4 = 304 ms of work to do per thread
I roughly got 304 / 2456 = 12.3% of the quantums from scheduler 3
@sp_BlitzErik right, but I'm using that CPU burning query
let's see what waits I'm getting
wait_type wait_time_ms
ASYNC_NETWORK_IO 147
SOS_SCHEDULER_YIELD 777771
pretty good imo
here's another one
wait_type wait_time_ms
SOS_SCHEDULER_YIELD 807596
MEMORY_ALLOCATION_EXT 0
RESERVED_MEMORY_ALLOCATION_EXT 0
 
what are the avg waits on sosy?
 
3:36 AM
nothing but SOS_SCHEDULER_YIELD!
what a lovely query
 
it's all signal wait
 
so?
 
so nothing
what are the avg waits on sosy?
 
here's what I get with just one busy session:
MAXDOP 4: CPU time = 2328 ms, elapsed time = 1520 ms.
MAXDOP 3: CPU time = 2484 ms, elapsed time = 889 ms.
@sp_BlitzErik how do I measure that?
 
run sp_blitzfirst :)
 
3:40 AM
I've always been too ashamed to run it
 
you can keep your gloves on
 
the download link I got doesn't work
send me a bootleg version
 
@JoeObbish Sorry coming into this late. What do you want exactly? A demo of that effect?
 
For 13 seconds over the last 5 seconds, SQL Server was waiting on this particular bottleneck.
that what you wanted?
 
3:43 AM
no
 
I ran the thing
what do I click on
 
run it like thusforth: EXEC sp_BlitzFirst @ExpertMode = 1, @Seconds = 5
or however long your dang query carries on for
 
good thing I don't mind lying to SQL Server
my query runs ALL NIGHT LONG
Wait Time (Seconds) Per Core Per Second Signal Wait Time (Seconds) Percent Signal Waits Number of Waits Avg ms Per Wait
14.6 0.9 14.6 100.0 1324 11.0
@PaulWhite No worries. I have a demo of this effect running right now
(internet died again)
@sp_BlitzErik did you get the message?
 
3:47 AM
what I'm after is a better understanding of this stuff, because I suck at it right now
 
i forgot why i cared though
 
Is this type of behavior one of the reasons people set CTFP higher than five? or am I overthinking it?
 
Setting CTFP higher is usually just a knee jerk to try to reduce the number of queries that go parallel.
 
that
 
hmmm
 
3:49 AM
though it is effective
 
But the behavior I'm seeing here
 
certainly
 
Isn't it a reason to be wary of parallel queries with MAXDOP N on a server with N CPUs?
 
Weary? Tired?
 
yes, I am
ok
is the counterpoint that if a server already roughly has its workload evenly distributed over schedulers
that in case you'll get better performance with MAXDOP N as opposed to MAXDOP N - 1?
 
3:51 AM
Pretty much
But it's easy to overthink this
and imagine we have more control than we do
 
so having a bunch of MAXDOP 1 queries is easy, as long as they aren't sent too quickly to the server
and having a bunch of MAXDOP N queries is easy
 
For specific applications, it can be worth the effort, but it's not trivial
 
but a mix isn't as easy
 
the other issue with parallel queries on that few schedulers is thread exhaustion
 
Scheduling has improved over time as well
 
3:52 AM
you get what? 512 for 1-4 cpus
many serial queries make it harder to run out of threads
 
512, yeah
 
considering the sloppy dopping
 
I once increased the number of threads on a server. Should I go to jail?
 
I remember the days of connecting and disconnecting until my concurrent bulk loads each got their own scheduler.
 
@PaulWhite we recently added something so that each job waits 2 seconds after the previous one
 
3:54 AM
WAITFOR IT
 
Yes that helps
Back in the day it wasn't always so easy
 
it was surprisingly easy to convince the developer to do it
 
As I say, scheduling has improved
 
I thought there'd be more pushback
man, I'd hate to see things in the old days
that was before RG too, right?
 
for paul it was probably before sqlos
 
3:55 AM
There's always a bleeding edge, it just moves around
 
right now we got an application that isn't using enough CPU on SQL Server
lots of serial queries
what do you think of "if everything goes parallel then nothing goes parallel"? for sufficiently active servers?
 
we're not OLTP and we're not that big
slide deck download doesn't work
and you never rated my query :(
 
not enough parameter sniffing
 
wut
 
4:15 AM
One of the important lessons is that round robin looks great but only works if resources are available evenly
 
@PaulWhite hash partitioning could have issues as well, but to a lesser degree?
 
Everything has issues, just different ones
 
example issue with demand? just skimmed your answer on the subject but didn't find one
 
@JoeObbish Demand is my favourite on balance, but it can be difficult to get
 
4:48 AM
And it's best for a small number of rows
If I had to choose one issue, it would be it only being available for Distribute
 
overall I feel less clueless on the whole
 
 
1 hour later…
6:13 AM
Well that's good.
 
 
2 hours later…
7:52 AM
morning all
 
8:14 AM
evening and morning
 
 
1 hour later…
9:19 AM
Morning
 
gbn
Good morning all
 
Hi
 
 
1 hour later…
10:38 AM
Hi and Bye
 
Well, this is a game-changer! Bye bye Windows! github.com/Microsoft/sqlopsstudio
 
11:06 AM
Morning all from Jakarta
 
Are there some cases where writes from system threads (e.g. ghost cleanup, page split) are attributed to a user SPID? I'm looking at a case where (@P0 nvarchar(4000))select val from myHeapTable where setting= @P0 run through sp_execute inside an implicit transaction is causing an LOP_BEGIN_XACT record to be written out, but only rarely when the query is run.
Extended events shows the command caused two writes.
 
11:25 AM
I'm going to try Ops Studio to avoid thinking about this.
 
o/
 
12:15 PM
@ConcernedOfTunbridgeWells What are you up to in Jakarta?
 
 
4 hours later…
4:07 PM
anyone jealous of my wait events? (301355046ms)EXECSYNC
 
is that columnstore-related?
 
no, checkdb related
 
ah fun
why's your checkdb taking 3+ days?
i think i've seen that wait when giant checkdb snapshot -> something tries to offline the db -> goes into unkillable rollback
 
we're being extra thorough!
more seriously, it's something along those lines
 
4:37 PM
I'm trying to load a series of CSVs on S3 into a Redshift cluster using the copy command and I'm getting the error "[Amazon](500310) Invalid operation: LOAD source is not supported. (Hint: only S3 or DynamoDB or EMR based load is allowed);". The source is definitely S3. Any ideas?
Specific command that I'm running looks like:
create table #Foo (
    --bunch of fields

    primary key (FooID)
);

copy #Foo
from 'arn:aws:s3:::mybucket/random_id/s3test.manifest'
manifest;
 
@mikeTheLiar not many redshift folks in here. You should probably ask a question on main
 
I suspected as much but I figured I'd give it a shot anyway.
 
 
2 hours later…
6:14 PM
@mikeTheLiar I'd probably even try SO - got better Redshift answers there
@JoeObbish no OLEDB?
 
@sp_BlitzErik damn right
 
How the hell is it all EXECSYNC?
What are you DOING MAN?
 
hey man I found it like this
I didn't do it
maybe I'll get to bake my wait event a birthday cake
HTH
 
6:46 PM
Helps what?
 
helps you to not forget
 
7:05 PM
we threw our hats in for a precon, so forgetting isn't optional
 
I figured it out. Changing it to from 's3://mybucket/random_id/s3test.manifest' was the secret. The full arn wasn't recognized as belonging to S3.
 
7:29 PM
Still surprises me sometimes how the easy answers get 20 votes
Then you post an answer you think is much better in another tag and only get 2 or 3 votes
Case I point the collation one I posted is seriously overrated
 
didn't see it
 
7:48 PM
@sp_BlitzErik I won't link it it doesn't need more votes
 
what makes you think i'd vote for it anyway
 
Fair point
You probably shouldn't
 
consider it not done then
 
@sp_BlitzErik which precon?
 
we applied to one at sql sat nyc, but i don't know if we'll get it yet
 
8:29 PM
@TomV Democracy loses to advertising
 
@PaulWhite are there any constructs in 2014+ that still reliably generate a 1 row estimate?
like mstvfs used to
 
@sp_BlitzErik Aside from table variables you mean?
 
yessir
free of all variables
 
If you want the 1 row mstvf you can use tf 9488
 
say that's not an option
because i have morals
 
8:32 PM
"that's not an option"
um
 
does that mean i do or don't have morals?
i'm confused
is there a trace flag for morals?
 
there ought to be eh
besides you didn't specify what sort of morals you had
Nothing 1-row leaps to mind
 
yeah, same
was thinking a itvf with empty scalar aggregate but no
 
@sp_BlitzErik really?
 
yeah
CREATE OR ALTER FUNCTION dbo.OneRow()
RETURNS TABLE
WITH SCHEMABINDING
AS RETURN
    SELECT MIN(h.c) AS dead_col
    FROM   ( SELECT CONVERT(INT, NULL) GROUP BY() ) AS h(c);
GO
SELECT *
FROM dbo.OneRow() AS o
JOIN dbo.Dummy AS d
ON ISNULL(o.dead_col, d.Id) = d.Id
with 1000 rows in dummy i get a 100 row estimate
 
8:37 PM
@sp_BlitzErik Ah but that's only because of the 10% guess
 
So you want something that produces a 1-row estimate no matter what you do with it?
e.g. no matter what you join it to?
I feel like I am missing something here :)
 
you're not
 
well that's a relief
 
 
1 hour later…
10:00 PM
@sp_BlitzErik no, I meant what is the subject of the precon?
@sp_BlitzErik are you still looking for assistance with this?
 
10:13 PM
@JoeObbish same as pass, don't have enough time to write all new material. If you have any feedback about that I'd love to hear it. For the one row thing, only if you're very bored. Mostly just curiosity.
 
@sp_BlitzErik would it be useful to hear feedback solely from thinking through the handout? it's a bit difficult to remember exactly what was said
 
sure, just email me
 
will add it to my list
I don't think I get the other question though. Does what you're describing exist in 2012?
 
yeah, mstvfs had a 1 row estimate pre 2014
 
but you could join them to something and get more than a 1 row estimate, right?
or do I have that wrong
 
10:25 PM
so if you have a mstvf that returns one null value, you can join to it on like t.id = isnull(mstvf.id, t.id) and the whole subtree would get a 1 row estimate
 
oh, so there are some restrictions
 
yeah you have to MEDDLE with it a little
 
I will try when I get home
new CE only?
 
ideally it would work anywhere, but you know
 
SQL Server:
let's say we have a table like:
create table t (val int primary key not null, value int);
declare @v int;

insert into t values
(2, 200),(1, 100),(3, 300);
what would be the value in @v?
 
10:31 PM
BA DUM CHING!
 
select @v = value from t;
it's always returning the last row, why?
select @v = value from t;
select @v;
 
@Sami the last in what order?
 
there is no order
this question was posted on SO, I'm trying to understand it
 
allocation order
 
You answered yourself. There is no order. There is no "last row".
 
10:35 PM
it you add another row with all 0s at the end it'll probably return that
that's the typical access path for a heap in sql server
 
@ypercubeᵀᴹ what I mean by the last row, is the last value inserted in the table
 
And even if it always returns the last row from the list that was inserted, who cares? Why would we want to use select @v = value from t; ? How "fast" would that be in a big table?
 
not determinstic or guaranteed
 
in this case is 300
 
@sp_BlitzErik I cannot even conceive what you need this for
 
10:36 PM
All the values were inserted in a single statement.
 
if you're writing the query yourself this is super easy to do
 
@JoeObbish at least my requirements are clear :)
 
you basically want something you can tack onto any query (without a query level hint) that will lower the estimate of the subtree to one?
 
@ypercubeᵀᴹ I know, who cares but I'm just trying to understand it
 
my power cord just went for a walk
@sp_BlitzErik clear as mud
 
10:37 PM
red mud
 
pfft
 
and does it need to work for any arbitrary subtree? or is the query level estimate enough?
 
10:54 PM
Hahaha, any arbitrary subtree is exactly how I'd describe it.
 
11:05 PM
edit the XML of the estimated plan
you're welcome
 
@AndriyM So, I'm right it will return always the last value
While I'm getting a rain of DV :D
 
"last value" is arbitrary without an order by
 
@sp_BlitzErik Did you see the question?
Also the answers
 
@Sami Well, your wording was, "the last row in the table", which is not the same thing as "the last value that is returned". By definition, rows in a table don't have an inherent order.
 
11:20 PM
aha, the meaning
my fault, I'm arabian :)
 
i understand the question, i'm only talking about your answer
 
Yeah, that was my fault, cause I mean by "the last row" the last value returned by a SELECT statement
which is the last value inserted in the list (I think while there is no order)
 
@Sami No, it could be any value returned.
Just because you observed a certain behaviour, it doesn't mean that it'll behave always the same. The row returned may be any of the rows of the table, in other occasions.
 
Hmmm... yes you are right
The last value returned by the select statement which can be any value, cause we don't know what is the last value returned by the select statement
Random
Thanks guys ^_^
@AndriyM Helpful comment :)
 
11:56 PM
When we use HASHBYTES is there any way to return the string from the hashed one?
for example:
CREATE TABLE HashedStrings (
    ID INT IDENTITY (1,1) NOT NULL,
    HashedStr NVARCHAR(MAX)
    );

INSERT INTO HashedStrings VALUES
(HASHBYTES ('SHA2_512', N'String1'));

SELECT HashedStr
FROM HashedStrings;
It will return:
 
I wish there was a way to approve answers to questions before they would show up
 
00:00 - 03:0003:00 - 00:00

« first day (2509 days earlier)      last day (2359 days later) »