« first day (2521 days earlier)      last day (2363 days later) » 
00:00 - 16:0016:00 - 21:00

12:02 AM
@JoeObbish that wasn't a plan, i just found it in the showplan schema
it's in 2016+
 
like Tom said it's not listed as an operator
I think they cut it
 
sounds like I should test with 254 FKs
 
Lamak linked that earlier, but the link dead ends
I had no idea this stuff was so interesting
 
12:08 AM
Ok I'm on my phone so
 
don't interpret that to mean that I don't appreciate it
 
I seem to recall there's a reason hash semi join can't be used for FK checks
 
it's not surprising to hear you say that
 
Maybe it's the probe column and role reversal
 
I know that I don't understand the details, but all it seems to be doing is creating a new expressions and evaluating them with an assert at the end
 
12:11 AM
@JoeObbish the ri operator?
 
@PaulWhite no, the merge joins in the example above
6 hours ago, by Joe Obbish
user image
trying to get the ri operator now
 
Ah the merge semi join doesn't list the probe column
 
with 254 Fks I get 254 merge joins
may have done something wrong
can a query even have 10k joins?
@PaulWhite btw I don't follow this
Msg 8623, Level 16, State 1, Line 288
The query processor ran out of internal resources and could not produce a query plan. This is a rare event and only expected for extremely complex queries or queries that reference a very large number of tables or partitions. Please simplify the query. If you believe you have received this message in error, contact Customer Support Services for more information.
well that went well
I GOT ONE
I was misreading the docs
I thought that I needed a table with 254 foreign key references to other tables
it might only be supported for a table that has 254 references to it
that's why all of the demos show a delete
(let me know if that didn't make sense, may have used the wrong terms)
 
@JoeObbish It's in this answer: dba.stackexchange.com/a/46361/1192
 
thanks, will check it out
that's one of my least favorite questions
 
12:27 AM
@JoeObbish Congrats!
 
@sp_BlitzErik Do I get a prize for uploading a plan for which there's no picture for an operator?
 
I remember disliking that new operator. Seems like a hack workaround.
Hiding a bunch of stuff behind a single icon.
Which might just as well be labelled "magic"
 
yeah
 
OTOH people with 10k FKs deserve it
 
it doesn't seem to fit their design philosophy
for operators
 
12:31 AM
Exactly
 
they said that it's faster
which makes me wonder why they don't always use it
 
No doubt
 
but there's another way to interpret that
probably can't generate a plan with 10k joins
so in order to support 10k foreign keys, they HAD to do some kind of magic like this
 
Well the old limit was 253 for compilation time reasons I guess
But still. Icky.
Next year, all execution plans will be a single operator called "execute query"
 
what else could they have done though?
 
12:33 AM
@JoeObbish there are many of those. it's expensive getting them all drawn.
 
think about the size of the XML
@sp_BlitzErik name one other one!
 
@JoeObbish Use json :)
 
paul's real favorite operator
not that sham compute scalar
 
did you know that json is more efficient than XML?
XML is for slowpokes
here's a demo that saves 1 ms
 
Loving that series
/s
 
12:36 AM
can you express that in json please?
 
{ strings faster than complex types shock horror }
 
Table 'FACT_TABLE'. Scan count 254, logical reads 860552, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
all of that hidden behind the operator
I wonder if I can reverse engineer what it's doing
 
Probably just looking busy
 
that probe column stuff seems really silly
you can get the same thing with T-SQL so easily
(for the foreign key stuff)
Table 'FACT_TABLE'. Scan count 254, logical reads 23387812
CPU time = 18015 ms, elapsed time = 18113 ms.
 
@JoeObbish How?
 
12:43 AM
hm
maybe I'm about to make a fool of myself
 
Hard to predict
 
this stupid operator does twice as many logical reads as I would expect
 
It's twice as logical :)
 
sys.dm_exec_query_profiles tells you absolutely nothing
 
What does your example look like? Fact table with 254 FK references?
Or self-references?
 
12:51 AM
@PaulWhite want a repro?
@PaulWhite doesn't this accomplish all that's needed for a FK check? pastebin.com/a2ZyHUC1
 
@JoeObbish sure
 
@JoeObbish might change the number of rows
 
@PaulWhite but there's a primary key or unique index on the other table? due to the FK relationship? right?
 
1:07 AM
ah, it does double the IO when I delete two rows
because it scans the table 254 * 2 times
the more interesting case would be deleting a lot of rows when indexed columns in the other tables
 
@JoeObbish Not following. Say you delete from the parent table (with the unique key) the check on the child table(s) will generally not have a unique constraint
(wife came home with coffee)
 
sorry, I completely switched gears
talking about inserting into a child table
seems as if hash match is not supported when checking that the key exists in the parent table
 
1 hour ago, by Paul White
Maybe it's the probe column and role reversal
I always wanted a hash semi join there
 
I still don't get what that means. is the probe column an artificial limitation?
 
I'm not sure of the details. Been a while since I thought about this.
There's no good reason I can immediately think of that hash SJ couldn't support probe
Though, as I say, it might have to prevent role reversal
 
1:14 AM
Maybe the Hash would be supported under "perfect" circumstances
 
maybe so
 
role reversal is using the inner table as the build?
 
But it seems odd merge is there
 
@sp_BlitzErik any idea what "perfect" means here?
 
@JoeObbish switching build/probe inputs on a spill
 
1:15 AM
oh, that thing
I've never seen that
 
yeah because estimates can be horribly wrong
happens all the time.
 
I remember reading about it
and thinking it was awesome
does the plan not tell you?
 
Nothing to show it happened in showplan sadly
Trace flags needed
 
Showplan is such a drag sometimes
 
Well they keep adding stuff to it. I do wish they'd think the new things through a bit more tho
And clearly they should switch to json for perf reasons
 
1:17 AM
I think the implementation of locally aggregated rows is wonderful
 
@JoeObbish In showplan?
 
@PaulWhite yes
 
Ah. Irony detected.
 
ok
so foreign key references check
isn't nearly as interesting as I thought
in fact, it's as dumb as a brick
 
go on
 
1:21 AM
it tells you what it will do for all of the FKs
in the details
index scan: [D1].[dbo].[FACT_TABLE].[DateKey132]=[D1].[dbo].[FK_DIM_TABLE].[DateKey]
it plans to do half a million scans of the table
and is cool with that
this is actually a legit example of RBAR
 
No wonder it's hidden behind a curtain
 
man, showplan is so dangerous during this testing
one wrong showplan and SSMS is gone
this plan shape is amazing
tell me that's not art
 
Modern art perhaps. I feel like I'm supposed to project myself onto the canvas.
 
but yeah, the magic operator has the same downfalls that you would expect
with 250 FKs I can influence the plan with query hints
and change it
with 254 I just get brick optimization
man
I've only spent a few hours on this and already have two outraged blog posts to write
three, I suppose
 
@JoeObbish prefer the colorized one.
 
1:36 AM
wow, you can get parallelism in that part of the plan
magic operator: CPU time = 83938 ms, elapsed time = 86988 ms
no magic operator: CPU time = 1031 ms, elapsed time = 1042 ms.
 
Well the blog post did say it was v1
I guess the aim was to make it work at all, for someone important somewhere
 
@PaulWhite @sp_BlitzErik I emailed my MS contact and already got a response
interested in seeing it?
 
sure
 
I took a screenshot which I'll delete in a few minutes
 
ho ho ho
 
1:46 AM
Extra crispy
 
maybe I should have saved that for the blog post
 
didn't one just come out
 
That was 2016
 
"The minimum required Random Access Memory (RAM)" - thanks for clearing that up KB article writer
 
2:07 AM
Nothing too juicy
Which means there are secrets
 
 
4 hours later…
5:50 AM
@sp_BlitzErik Funny story. My first time to Kuala Lumpur I stayed at the Armada Hotel. In their booklet they had a list of things to do. One was to visit the night markets (pasar-pasar malam). The brochure said advertised it as "a hotbed of triad activity" where "you can find all kinds of contraband."
@EvanCarroll It's actually interesting. When I got the job at Adjust I had to pass a C coding challenge which was a bit of a challenge because I had not touched C in 15 years basically since I taught myself it and basically wrote Perl in C. Since I started I have worked with good C programmers and upped my C game a lot.
One of the people I work with here is involved in writing operating systems and tends to advocate using the stack for as much memory management as possible.
But knowing how palloc works and memory contexts is a very nice thing and I totally agree with using the same basic approach for clients too.
 
@PaulWhite thanks for the edit
 
6:12 AM
We need a book on PostgreSQL internals, I've read the Tom Lane ebook but it's wayyy out of date.
I think it covers the v0 function calls.
I think in another year I'll be a lot better at it. Rust and modern C are two things I've got on my todo list, and next years tech-new years resolution is to dive into Pg internals.
 
6:39 AM
@EvanCarroll yeah, regarding a need for a book.
@EvanCarroll it's easier to dive into the internals if you have to or have a specific use case. ;-)
 
morning all
 
6:55 AM
Morning
Hey @PaulWhite, do you think you could unfreeze our Trash room?
 
7:08 AM
@PaulWhite They nuked the leaderboard for 2016 =(
@PaulWhite that's alright, I don't remember how well I did last year, but I remember you beat me.
@AndriyM Is that where they put all the fun conversations with too much awesome.
 
@EvanCarroll I guess that's one way of putting it
 
@ChrisTravers I'm down if you've got a use-case. =) I'm just unsure of my abilities right now with your work load or whether or not I'm the best guy for the job. I do full stack web dev, rest apis, and work with open source scripting languages, angular and the like. But I've done pretty much everything from arduino on up. I also work with functional reactive programming with rx.js which seems a lot like the Apache project you linked yesterday.
 
8:04 AM
@EvanCarroll But that was only on Ubuntu. You keep root for localhost logins and disallow login from SSH with root. That way you keep the baddies out.
 
@EvanCarroll The problem is that most of the right people for the job work for about 3 companies (2Q, EDB, Citus, and maybe a few others). I don't expect to find a perfect match. Getting people who can jump in and become the right person.... that's probably where it is at.
 
evening and morning
 
Happy days everybody.
@EvanCarroll Good answer. I'll let you know if there is a better one...
 
8:50 AM
Why is it that writing job descriptions is so much harder than writing C plugins to Postgres? :-P\
Looking forward to getting back to writing the background worker this afternoon.
I think human problems are way harder than technical problems. Which is probably why it is easier to scope variables than scope requirements.
4
 
 
2 hours later…
11:17 AM
Irony abounds..
user image
5
 
12:07 PM
I voted to reopen. — ypercubeᵀᴹ 3 hours ago
Please vote to reopen (we don't have the chance to say this often!)
I want to answer with my favourite motto. "If this happens, it's a bug"
 
@ypercubeᵀᴹ I voted because I saw the revised version in the queue.
 
@AndriyM Sure. Is there some advantage to doing so?
@EvanCarroll I think you came third. Maybe second? @ypercubeᵀᴹ might recall.
 
12:23 PM
@PaulWhite A couple of recent messages seemed to belong there much more than here and I didn't feel like moving them to any other trash room. Now I'm not sure I'm as concerned about them as I was in the morning. Sorry. If there's still any argument for unfreezing it, I guess for me it would now be "to keep it handy".
 
@AndriyM Does it being frozen prevent you from moving messages to it?
Honestly I have no idea if that's the case or not.
I guess you wouldn't be asking otherwise, but I'd appreciate someone confirming it.
 
@PaulWhite Looks like it does. The room doesn't come up for me when I try either the name or the ID.
 
Seems like a bit of a drawback if so.
Hm
1 message moved to Trash
 
I can see it now, thanks.
 
@sp_BlitzErik What's a 311 in NYC?
 
12:28 PM
Incidentally, using the ID doesn't seem to work
(when specifying the target room)
 
Weird. Thanks for the testing.
 
@ChrisTravers that sounds like the best place to shop. i'd buy machine guns and ladyboys and start the world's most homronally ruthless army.
 
Trash has been frozen for inactivity
I blame @JoeObbish for making this room so serious
 
@hot2use 311 is 911 light. 911 is for emergencies, 311 is for other complaints.
noise complaints, landlord complaints, etc.
 
query complaints?
 
12:32 PM
Execution plan complaints in particular
 
@sp_BlitzErik Got it. Cheers. Was looking in to the links you posted.
Any idea what database system it runs on?
 
@PaulWhite Not sure. We should ask bluefeet!
 
@sp_BlitzErik 911 is also what you get when you forget to dial international access and try to call New Delhi
 
Is it possible to prevent users from UPDATE/INSERT int a table while my PROC runnig, in the same time they can do a SELECT?
SQL Server
If yes, then how?
 
5
Q: Lock table while inserting

JBoneI have a large table that get populated from a view. This is done because the view takes a long time to run and it is easier to have the data readily available in a table. A procedure is run every so often that updates the table. TRUNCATE TABLE LargeTable INSERT INTO LargeTable SELECT * FR...

@Sami Have a look
 
12:42 PM
@hot2use no, not sure. the files i've seen exported were all text/csv though. so i don't think it matters much.
that being said, it did take a lot of work to fix some of the files in the mta turnstile data
at one point they completely change formats and don't tell you
just like real life!
 
@McNets Thanks, but I think WITH (HOLDLOCK) will prevent the other users from SELECTing too
 
@ChrisTravers i've managed to avoid that scenario!
 
@sp_BlitzErik Me too so far
But apparently it is remarkably common.
 
gbn
@ChrisTravers An unhealthy fascination with "911" methinks.
 
@Sami Have a look at TABLOCK or UPDLOCK
 
12:52 PM
@sp_BlitzErik Makes it hard to commute > On November 7, 2014, New York City’s default speed limit was changed from 30 mph to 25 mph.
 
having solved all of the city's other problems...
 
:-)
I bet...
 
1:28 PM
@sp_BlitzErik now you can make use of your screwdriver
 
i already drank it
 
just wanting to see what people think of this here.
So I have a situation where I have to do some bulk writes directly from one Pg db into another and the foreign data wrapper is not going to work since it writes one line at a time.
so the current approach is to implement a copy bulk write interface.
and two phase commit.
the issue with two phase commit is the cleanup if we don't get immediately to a globally consistent spot
So my thinking is to fire up a background worker to handle the cleanup.
(which can the happen after the transaction locally completes or rolls back)
anyone have any ideas as to this being a bad idea?
 
1:43 PM
just playing devil's advocate: is there a reason you're not bulk moving the data to a staging area and then doing the bulk writes locally?
 
this moves data into a staging area on another server which then does more bulk writes locally.
 
gbn
2:03 PM
@ChrisTravers Does/should data get removed from the source DB, after loading into new DB?
 
this is an incremental transformation so it doesn't get removed but it is marked as processed.
 
gbn
Is it idempotent on the target server? (INSERT .. NOT EXISTS or similar)
 
I don't think it is to be honest.
 
gbn
Breaking it down
1. Export source to staging
2. Staging to target
3. Update as processed on the source

If step 2 fails, step 3 does not run -> next batch just tries again with missed data and new data

If step 3 fails, data gets reloaded but anything already there is ignored
You may be able to have step 2 and step 3 in one transaction (possible in SQL Server)
I'd also use a Session identifier for each run, tracking in a separate table, and an extra column in the staging table This would be used for an later cleanup of staging.
Basically what I did a few years ago, where source was a risk calculation engine. Of course no need to write back to it.
tl;dr don't do it transactionally; do it in stages and with idempotence
 
2:22 PM
On a data warehouse:
i. Put foreign key relationships between the fact and dim tables. You can disable them during a load for performance if necessary.
ii. Most DW queries are table scans of the fact table anyway. Unless you're only bringing back a small fraction of the rows (few % or less) it is more efficient to do a table scan.
iii. It's worth putting indexes on fact tables if you have a significant amount of query traffic that is selective enough for the indexes to be worthwhile. By and large, the optimiser will just ignore indexes that aren't selective enough anyway.
@ChrisTravers Can you do 2PC natively on PG? (i.e. does it support XA?)
 
@ConcernedOfTunbridgeWells Yes
 
@ChrisTravers Can you (as @gbn suggests) batch it and use XA to coordinate updates on both sides?
Pretty sure the Open Group will let you download the API docs/spec for XA for free.
 
If I had all the time I need, I would probably decouple even further than that.
 
I don't think XA is all that complicated. You could do it from C or Java easily enough.
If your client wants this to be 100% reliable then they might have to wear a bit fo cost.
Get what you pay for and all that.
 
Yeah the XA part is easy.
the problem is: if between the prepare and the commit something dies
 
2:31 PM
@ConcernedOfTunbridgeWells foreign keys are the worst thing ever
 
you need a process to continue to retry the commit until successful.
 
besides, we got columnstore
@TomV how's that?
 
@JoeObbish Nothing special
trash being frozen for inactivity is a sign there isn't a lot of crap posted in the last few weeks
 
gbn
@ChrisTravers My approach might be to abandon it. And try again later. And clean up overnight based on Session GUID
The coordination is then "big staging to target write, small write back to update session"
 
@TomV you're welcome
 
2:42 PM
Evening
 
@TomV you mean "while erik was traveling"
-_-
 
hello
 
@ChrisTravers Normally you would use a TP monitor for that, although that might get you into large sums of money. Never seen an open-source one that was discrete from a bean container.
 
does anyone know if this works if the two databases in question are on a different server?
 
@ConcernedOfTunbridgeWells Ok so XA in PostgreSQL is such that once you ask if a transaction can be committed it becomes immutable and guaranteed commutable. I.e. if someone trips over a power cord when the server comes up you can still commit the transaction.
 
2:49 PM
@WhatsThePoint Assuming the versions are more or less the same I would expect it to yes
 
bt that also means that things like auto vacuum cannot clean up things older than the oldest open or prepared transaction.
 
Are there any good way to dive into a database you don't know the relations of? My first thought was to put it into something like Visual Studio and get it to map the relationships visually.
 
@TomV database is exactly the same just that the diagram was made on sqlexpress as we didnt have privelages (3rd party hosting) now we have our own server so we have the privelages to make the diagrams so i need to put them on new db but making them again is tedious
 
If you don't have an off-the-shelf TP monitor this might be getting into can-of-worms territory.
 
@WhatsThePoint I meant SQL Server versions
 
2:53 PM
yes i assume theyre the same, i can check
 
Having said that, there are actually a few open-source TP monitors in circulation now.
 
@WilliamMariager you could create a diagram in SSMS
 
@ConcernedOfTunbridgeWells I actually don't think it is so bad. Basically you need a guaranteed log. You need enough info in it to make appropriate decisions and you need a cleanup process that can run through the log and make appropriate decisions at the end.
 
Most of the other ones seem to be tied into bean containers.
Maybe you could do it with a message queuing system like RabbitMQ?
 
2:54 PM
@TomV diagram created on 2012, target db is 2014, is that an issue?
 
@WhatsThePoint Not sure, depends on if the table definitions/storage format changed, I'm not sure that's even documented
 
@ConcernedOfTunbridgeWells Long-term I am thinking Kafka
but Endurox looks interesting. Thanks.
 
@Lamak Ah, I see.
It's asking me to install "helper objects"
 
RabbitMQ has funny fsync behaviour
 
@WilliamMariager weird
 
3:07 PM
@WilliamMariager "support" objects?
yes you need to create those
it's basically a table and a bunch of procedures
 
3:25 PM
@ChrisTravers have you tried BDR's master-master replication?
 
@EvanCarroll Not yet but it looks promising.
(Not really applicable for what I am doing here by the way though)
 
3:40 PM
@sp_BlitzErik Can I pick your brain about partial aggregates?
 
slim pickins, but sure
 
it's not a concept that I'm great with
let's just consider a simple parallel DISTINCT query
a hash match (partial aggregate) gets the unique result set per parallel thread
later on we need to gather streams so we can remove rows that show up on multiple parallel threads (global aggregate)
right?
no batch mode here
 
Not sure if it fits into your specific work load or not. But it sounds like if you're not looking to use master-master replication then likely the same code the wrote to the run the plugin overlaps with your task
@ChrisTravers it seems what they do for BDR is run the same version of the code, and then send the datums as binary from one server to another without parsing them at all.
 
@EvanCarroll But with BDR these are tied to a point in the source wals I think so in theory you can replay.
 
I would assume that's true, is that a problem though?
 
3:49 PM
@JoeObbish it's funny -- i'm thinking through and it i'm coming back to the blog post where you figured out which rows were gonna end up on which thread
 
I got a funny story too
just read an entire Craig Freedman blog post to make sure that I wasn't being an idiot
"If a partial hash aggregate runs out of memory, it simply stops aggregating and begins returning non-aggregated rows."
 
what kind of data is the distinct on?
lol
joe sack sits next to him. every day.
 
sigh
Memory Fractions Input: 0, Memory Fractions Output: 0
I can't remember ever seeing 0 before
so the hash match doesn't even get a memory grant
but it also can't spill
what a wonderful implementation
 
brb call
 
00:00 - 16:0016:00 - 21:00

« first day (2521 days earlier)      last day (2363 days later) »