« first day (2335 days earlier)      last day (2524 days later) » 

12:01 AM
@sp_BlitzErik there's probably some technical reason
 
@ypercubeᵀᴹ for which part? heh
 
"the lack of parallel backwards scans"
 
ah, perhaps~
 
I haven't read all the discussion. I assume this is some optimization that hasn't been implemented. Correct?
 
yessir
 
 
1 hour later…
1:32 AM
@sp_BlitzErik I considered editing your post to use a LEFT OUTER JOIN, but I remembered that fun isn't allowed
 
@JoeObbish stack exchange is FOR WORK
 
speaking of work, you've been answering all of the good questions lately
along with some not-so-good ones
 
ahem
i was going for the peer pressure badge
but alas, after 24 hours, i was still at 0
and not enjoying the hand wringing/hysterical comments
 
did I miss a good one?
 
no, apparently not
i've been on a different kind of client work lately and working on a couple new stored procs, so i've had more time to uh... how do you call it
poop post on here
 
1:38 AM
I just helped you out
 
i see
I SEE
 
1:51 AM
Please avoid extended discussions in comments. Would you like to automatically move this discussion to chat?
the man noticed
 
i'm touched that that got considered an extended conversation
 
swoons
 
2:05 AM
oddly enough I learned of a plan to use BLOBs in SQL Server at work this week
as far as I could tell the end result would be that SQL Server would be used as very expensive file storage
 
i've seen more than one app try that and it always ends in sadness
 
I both like SQL Server and appreciate a good challenge
but I'm trying to convince them to reconsider
 
the ram investment alone can be prohibitive depending on file size etc
 
would you recommend it for storing images of my personal heroes in the SQL Server community?
 
you would only have one picture
so i wouldn't be opposed
 
2:11 AM
surely you're not so naive that you think your legions of fans only have a single picture of you?
so how do you feel about MERGE?
 
tried it, didn't like it
 
I'm a MERGE user
can write it on multiple platforms without looking up the syntax, for most parts
but so many people hate it that I'm trying to reconsider
 
have you ever run into any of the problems aaron has noted with it?
 
not as far as I know
the big part that I disagree with is when people seem to say that MERGE will never be faster
 
i don't say never, but when i tried it, writing separate inserts and updates was faster and seemed to lock things up less
that may have been during my "i'm going to be known for dynamic sql" phase
 
2:18 AM
oh man
how'd that go for you?
 
still in it
 
recently I've seen a fair number of stored procedures full of dynamic sql
I haven't figured out an efficient way to read the code or debug them when there's a problem
 
i tend to add a debug param and then print stuff if it's 1
reading it is kinda awful unless you know the code
 
I tend to read stuff once and don't look at it again
did google's home page change for anyone else?
 
i haven't noticed
 
2:59 AM
I'm proud to say that I've now generated more than 100 GB of nonsense data for SE purposes
 
how's that?
 
just sample demo for answering or asking questions
sometimes I forget to truncate or drop the tables
 
what is the name of this data set?
 
it's the SE_DB
it's the hottest new demo database
it's great if you need sequential integers because it's at least 25% that
 
3:19 AM
go on
 
there are over 150 tables!
 
how do you know what's in them all
 
most are heaps
because heaps are beautiful
I use a very disciplined and descriptive naming scheme
 
the eyes of someone who wants access to my demo database
 
3:35 AM
i'll stick to stack overflow
i wouldn't know what to do with that
except yell at it
 
so I got a query here which apparently runs faster as a MERGE than an INSERT
all the merge does is insert data
 
poidh
 
not sure how to take a pic of that
 
make a gif
obviously
 
3:50 AM
you just saw my demo database
and you've seen my screenshots
yet you think I have high production values over here?
 
hope burns eternal
 
this is actually really funny
 
i'm waiting pal
until i finish writing this godforsook case expression
 
working on my presentation
see the performance tip at the top of the MERGE article?
 
4:06 AM
which one?
 
it's their demo
check out my improved performance
only 50% more CPU time
this was the same thing that I ran into
then I checked the article and saw that example right at the top
warning us against inappropriate merge use
 
i'm exhausted so i'm gonna ask a dumb question
don't you insert a lot more rows in the first one?
 
I hope not
no, both cases I insert 100000 rows
it's in the statistics output
 
4:18 AM
yeah, sorry, i missed it
dbfiddle is not kind on bleary eyes
i think it's how the world looks to dogs
minus any joy
 
my theory is that it's due to halloween protection
I can't figure out how to write the insert without that stupid spool
maybe there's some sneaky way
but the merge doesn't need halloween protection
perhaps because of the limitations around the ON clause? not sure
personally, I prefer to just insert data into a table instead of inserting it into a table spool first
I'm out, good luck with what you're working on
 
5:26 AM
@JoeObbish I have an article about that
 
5:44 AM
and part 2 for the insert self-reference
 
 
3 hours later…
8:55 AM
For lover's of Deadlock art I give you this one With just around 122 Process ids involved in this one...… https://twitter.com/i/web/status/868092774998040576
 
 
2 hours later…
11:18 AM
The workplace never ceases to amze
97
Q: Someone forged my resignation letter

Kumal JSo about six weeks ago, my mother’s illness took a turn for the worst, and I took some time off work to take care of her. It was all very rushed because we never expected her condition to worsen so quickly and things were just very messy. I was also pretty stressed at the time and perhaps I didn’...

Today ^^^^
Yesterday, another one:
127
Q: HR at my new job just sent me an email saying that I am a volunteer. I've been working here two months under the impression that it's paid work

OmegastickI started a part-time software development job two months ago. The company I work for has roughly 50% volunteers, but the position I applied for was paid (I still have a copy of the job advertisement). I asked a question about how I should submit my time sheets to get paid, and they replied, "As...

So 2 nice ways, to either get rid of an employee or having work for free ;)
 
 
2 hours later…
1:17 PM
@ypercubeᵀᴹ Ooh, TomTom is still alive
Well, yes for the amounts, but you will find that in pretty much every jurisdiction forgery is a non trivial crime with jail time attached. — TomTom 23 hours ago
 
1:33 PM
1
A: How to make an OUTER JOIN return ZERO instead of NULL

ypercubeᵀᴹYou can use either ISNULL() or COALESCE() function: SELECT BlogID = B.BlogID, BlogUserMappingID = COALESCE(BUM.BlogUserMappingID, 0) -- ... or the more verbose CASE expression: -- BlogUserMappingID = CASE WHEN BUM.BlogUserMappingID IS NULL -- THEN 0 ELSE B...

@ypercubeᵀᴹ Why is tagged as community wiki this answer?
 
@McNets I tagged it like this.
 
@ypercubeᵀᴹ what is the purpose of this tag?
 
The poster doesn't get points from upvotes / downvotes
Usually when it's an answer gathered from other people's comments
 
Can anybody use it or mod rep is necessary?
Oh I see the check
 
Anyone
 
1:41 PM
@ypercubeᵀᴹ thank you.
 
But you can't undo
 
ok
 
@PaulWhite thanks
 
2:44 PM
training.
0
A: How to left join and count two tables where the rows (strings) are different

McNetsAs @ypercube has pointed out on his comments you can use replace() function in ON clause to compare both strings and get the desired result. select title, path from t1 inner join t2 on 'path/' || replace(t1.title, ' ', '-') = t2.path; title | path ...

 
 
2 hours later…
4:23 PM
@PaulWhite of course you do :)
I know that it's harder to get minimal logging with merge than insert
but otherwise if I'm guaranteed to have only one process changing the table, it can be argued that MERGE is a better choice than INSERT?
 
@JoeObbish Impossible AFAIR
@JoeObbish If it goes faster or is otherwise 'better' in a particular scenario than yes, it is a better choice :)
 
I'm quite fond of the hole-filling optimization, but my experience has been that it all too often fails to materialize, or other non-MERGE methods turn out to be 'better'.
 
@PaulWhite Well, what I mean is that I generally try to avoid things that BOL directly says not to do
 
@JoeObbish What are you talking about exactly? Sorry I was working on something else completely non-merge related so I am lacking context.
@JoeObbish That's interesting - it's a shame the comment "How can this be when MERGE doesn't explicitly enforce a SORT order?" was never replied to.
 
4:37 PM
in some places in code we do things like this:
INSERT tbl_A (col, col2)
SELECT col, col2
FROM tbl_B
WHERE NOT EXISTS (SELECT col FROM tbl_A A2 WHERE A2.col = tbl_B.col);
considering using MERGE instead
but the top of the MERGE article on BOL says specifically not to do that
Performance Tip: The conditional behavior described for the MERGE statement works best when the two tables have a complex mixture of matching characteristics. For example, inserting a row if it does not exist, or updating the row if it does match. When simply updating one table based on the rows of another table, improved performance and scalability can be achieved with basic INSERT, UPDATE, and DELETE statements. For example:
 
Yeah well BOL is good as a beginners' guide but it does lack detail at time and, like all things, also contains errors.
It's good general advice, but that doesn't mean they're aren't exceptions.
I have found MERGE to be better than any of the alternatives exactly once in a production system.
 
right, this whole thing started because it seems like a lot of people in the community have similar opinions
and we use it more than once in production
do you have a better way offhand to rewrite the insert above?
oh
it might be part 4 of your article
 
"Better' is just completely dependent on the circumstances. I wrote part 3 because the hole-filling optimization is genuinely an optimization people should consider. It is just as safe under concurrency as other methods btw.
My personal experience has been that I have not been able to use it as successfully as I had hoped, for one reason or another.
 
0
Q: Way to drop all views and functions owned by PostgreSQL role?

DaveIs there a command in PostgreSQL for dropping all views and functions owned by a particular role? I don't understand how all the internal tables are connected together so that I can create such a command.

1
Q: Drop all views and functions owned by a role in PostgreSQL?

RobertIs there a command in PostgreSQL for dropping all views and functions owned by a particular role? I'm reading the Postgres docs but having a hard time understanding how all the internal tables are connected together so that I can create such a command.

 
4:54 PM
@McNets Thanks, but feel free to raise a custom mod flag in future. Chat messages can be missed.
 
@PaulWhite I'm not sure about it's the same OP
 
@McNets Check their network profile. Same person.
 
@PaulWhite ok
 
@JoeObbish For example, your demo works faster for me as a hash right anti semi join.
Writing the rows to a temporary table then doing an insert is also competitive.
 
I've suggested to the OP that they ask about shortening multi-word strings in a new question. Please consider removing your answer from this thread and re-posting it in the new one once it (the new thread) appears. Addressing tangential points raised in comments makes questions messy and is really against the format of this site. Thank you! — Andriy M 6 mins ago
Fair call?
 
5:00 PM
@AndriyM stefan thought so
 
Yes, he's just answered. I needed just a tad more patience.
 
@AndriyM And of course you are right. He could also post a self-Q&A as an alternative.
 
@PaulWhite Yeah I was just going to try that
it seems a bit unfortunate that the table spool cast for the eager spool is almost nothing
 
@JoeObbish Cast = cost?
 
yes
 
5:07 PM
The other thing about MERGE is that compute sequence that cannot go parallel.
@JoeObbish Is it really so unrealistic that a (largely) in-memory write and read of 100k rows in an optimized format is a bit cheaper than merge joining 150k and 100k rows?
Don't get me wrong though - it would be awesome if hole-filling was inplemented for INSERT...NOT EXISTS.
I imagine that would be rather more complex than it sounds though.
 
@PaulWhite My issue is comparing the insert queries
in one case we get an eager spool on disk (right?)
in the other we get a sort which is fully in memory
 
@JoeObbish Comparing which insert queries exactly? I cannot see your screen.
 
the sort is 150X more expensive to the query optimizer
INSERT tbl_A WITH (TABLOCK) (col, col2)
SELECT col, col2
FROM tbl_B
WHERE NOT EXISTS (SELECT col FROM tbl_A A2 WHERE A2.col = tbl_B.col)
OPTION (HASH JOIN, MAXDOP 1);


INSERT tbl_A WITH (TABLOCK) (col, col2)
SELECT col, col2
FROM tbl_B
WHERE NOT EXISTS (SELECT col FROM tbl_A A2 WHERE A2.col = tbl_B.col)
OPTION (MAXDOP 1);
I know that the query optimizer won't deduce that the data is already sorted and lower the cost of the sort on that basis
 
@JoeObbish The output of a hash join has no sort order.
 
oops, got my queries mixed up
still partially asleep here I guess
 
5:22 PM
The Sort in that query is costed as a normal sort. Yes it will ideally be completed in memory, but a sort is still quite an expensive operation.
The eager table spool has a low cost because it uses an optimized format that will reside mainly in memory, backed by tempdb. It is an awful lot cheaper than accessing 'real' relations via the normal storage engine interfaces.
Which is not to say that spools can't be slow and expensive - they can - but they're costed low for a reason.
 
I didn't know spools were mainly in memory
 
And to preempt, no, spools don't use memory grant. They use regular pages in the buffer pool with optimizations to delay or avoid writing them to the backing store (tempdb) and with greatly reduced logging.
 
I would give you the last of these homemade cookies if I could!
 
@JoeObbish Funnily enough Amanda (my wife) brought home some homemade cookies today.
 
that's a very unfortunate typo...
 
5:29 PM
The butcher's wife uses her empty shoe boxes as the basis for charity gift boxes she makes, so she gave us some cookies as a thank you.
@JoeObbish Ha ha ha! Fixed.
 
why did your wife have so many shoe boxes?
 
@JoeObbish She works part time as the manager of a shoe shop
Many customers don't want the boxes, just the shoes.
 
ah, I thought you were going to say that she loves buying shoes
 
Well.
 
huh, I always take the boxes
but I own only three pairs of shoes
 
5:31 PM
Well so long as you aren't buying your shoes in Paraparaumu, you're not depriving any orphans so I guess that's OK :)
 
Good idea. I'll meet up with you for some SQL help and your wife for some new shoes
my shoes are looking pretty bad these days anyway
ended up staying up pretty late two nights ago baking
 
The cookies are rather nice. I had three with a cup of coffee earlier.
 
a friend at work ended up retiring much early than expected due to health issues
he was an amazing developer and very helpful to lots of people
it's just a really sad situation for many reasons
 
What did you bake?
 
my very best: double chocolate
no nuts for allergy reasons (of others)
 
5:34 PM
Nice.
 
had to ambush people in the hallways and in meetings after the party to get rid of them all
it's said that an important rule for baking is to give what you made to other people as quickly as possible
 
Makes sense
 
I still have no concept on how people can come up with their own recipes
except through trial and error
 
We here both have pretty basic kitchen skills, but so many of our friends seems like they should be on MasterChef it's quite intimidating
But we're more than happy to eat the things they make of course
One of the most productive ones has sadly just left for a couple of years in the UK and Europe for her OE.
So I guess we'll need to replace her at least temporarily :)
@AndriyM I deleted that answer and left a comment about self Q&A
 
@PaulWhite OK, thanks.
 
5:43 PM
I know what you mean. One of my friends consistently makes food for large quantities of people (50+)
same job as me
I can barely manage to make food for one
it seems as if my baking skills are good based on the reported final outcomes, but I often fret when making things
since it often doesn't go according to plan
 
6:05 PM
Tough to beat a good cookie :)
 
6:21 PM
I made homemade donuts once
fried and everything
that was an adventure
 
7:21 PM
Just about to make chicken kebabs. I've only just realised that anyone can be good at cooking. Just follow the recipe!
 
7:33 PM
Black rice
 

« first day (2335 days earlier)      last day (2524 days later) »