« first day (4298 days earlier)      last day (869 days later) » 

00:09
Nope, only used the ones I linked to
 
7 hours later…
06:47
morning
07:05
Morning
 
1 hour later…
08:25
What is the question here? Row level locks get escalated to Page or Table level locks depending on how many rows need to be locked. So it is possible for unrelated rows to be locked, under certain circumstances. — J.D. 7 hours ago
@J.D. Row level locks never escalate to a page lock. If you'd written your answer in an answer, you could have edited it.
The question here was in the sentence ending in the question mark and you answered it despite your claim you didn't know what it was. This lock escalation to unrelated rows is unfortunate, but thanks for the answer. If you post that as an answer, I'll accept it. — John 5 hours ago
And the OP wouldn't need to write all that.
And I wouldn't have anything to clean up.
For the absolute love of small fluffy bunnies, please write answers as answers. Even if you're not sure it's the answer. Use comments for asking for clarifications by all means. Do not attach an answer to such comments. I am pleading with you now.
3
 
1 hour later…
09:35
A chairde - Morning all!
10:16
Draw with Zikato. I managed to escape his fierce play!
@ypercubeᵀᴹ too good
Oh look at that
False flag
More comments to delete, time to make the donuts
I ate rabbit the other night. It was that or duck. It’s almost like all cartoon characters end up on a plate.
Good evening from tropical Amsterdam
Answer given. Our mod is now free to eradicate all those comments ;)
Eradication escalation
@PaulWhite Just trying to keep you busy. 😉 Just kidding, fair enough, comment deleted, apologies.
11:54
others are also keeping Paul busy
@a_horse_with_no_name Ок, если по простому, мне нужно понимать, какой именно запрос потребляет память. Т.е. в момент выполнения тяжелого запроса PLE упадёт или сильно просядет. Собственно для такого анализа мне и нужен PLE. — aqis 16 mins ago
 
1 hour later…
13:07
Paul, why are you making me do work
13:24
It’s your job
🤔 I need a new job
One where I preferably don't have to do anything
@PaulWhite Erik ate them already 🤷‍♂️ (fluffy bunnies)
13:49
@SeanGallardy that’s called consulting
14:00
@ErikDarling I need to get on that, I guess
@SeanGallardy Small fluffy kiwis would've gotten my attention better anyway. 😁
TOP 1 WITH TIES ordered by ROW_NUMBER
What the heckin heck
14:23
Is that supposed to be more efficient in some way? There can't actually be ties for that ORDER BY, right?
In that particular case, there can be ties
OK, read whole article. That design should not allow duplicate _ValidFromDateTime for a particular customer because that looks like a validity period - where you wouldn't want them to overlap. So that query is accounting for something that probablyshouldn't be allowed in the first place.
I cannot recall ever having a case where I wanted to use WITH TIES, and certainly not in that kind of scenario - I've always found something to disambiguate the rows or decide it was a sign of a larger problem.
15:13
It'd be more efficient at this point to start shooting people using that instead of trying to explain everything
This Microsoft example code appears to indicate that writers won't block other writers under SNAPSHOT isolation, if implemented correctly. Are you certain every connection is setting the transaction isolation level to snapshot? — Hannah Vernon ♦ 3 hours ago
Indeed, snapshot isolation produces write conflict errors, not blocking
15:33
so does it still take locks, under RCSI? I'm officially confused now
No.
SI and RCSI are very different.
Neither take locks when reading. SI detects write conflicts
It's very hard to summarise all the behaviours succinctly.
RCSI is a versioning-based implementation of read committed.
SI is a new isolation level.
> When a data row meets the update criteria, the snapshot transaction verifies that the data row has not been modified by a concurrent transaction that committed after the snapshot transaction began. If the data row has been modified outside of the snapshot transaction, an update conflict occurs and the snapshot transaction is terminated. The update conflict is handled by the SQL Server Database Engine and there is no way to disable the update conflict detection.
In case you weren't confused enough, SI transactions do still take exclusive locks:
> Transactions running under snapshot isolation take an optimistic approach to data modification by acquiring locks on data before performing the modification only to enforce constraints. Otherwise, locks are not acquired on data until the data is to be modified.
I mostly ignore the SI if I'm already using an RCSI. And when I use it, it's for read-only queries
Is that also available in English
The other important difference being RCSI generally uses a snapshot as of the start of each statement; SI uses the same snapshot as of the start of the transaction
I say "generally" because non-inline functions start a new snapshot too
So, a single statement under RCSI can access data from n different 'points in time', if the statement contains n-1 functions
Anyway, Erik tells me RCSI and SI are much simpler than the other isolation levels
So how would be possible for a writer to block another writer in SI? From the docs, I'd assume that the writer that tries to write in pararllel with another one, will either succeed or get a write conflict.
There's no blocking if the other writer is also using SI
15:48
the question linked though claims otherwise: stackoverflow.com/questions/1044164/…
> However, in practice, when one person halts a transaction while debugging, all other DB users attempting to access the same rows are blocked despite using snapshot isolation level.
Hence Hannah's comment
It's possible they're getting blocked on a FK validation, but more likely they're just doing something wrong
We may never know
Oh, hang on I see what you mean
T1: w1
T2: w2 blocks under SI if T1 hasn't completed its transaction yet
If T1 rolls back, T2 completes without error; otherwise write conflict
Great, I even managed to confuse myself
2
Far out
16:09
I see, yes. Looks familiar to Postgres' behaviour.
It's confusing because the example H links to is a different scenario
yeah
and locking <> blocking
right
I don't much like the example because it sort of implies you have to read the row before later trying to modify it to get a write conflict error
You just need to have started the SI transaction by reading something in the database to set the reference row version. Any attempt to modify a row with a later version than that will produce a write conflict error.
In other words, just issuing BEGIN TRAN doesn't set the reference point. You have to do something.
@ErikDarling For some reason I've been thinking all day you're in Germany or Austria
16:17
@PaulWhite Erik says they’re preferable, excuse you.
@PaulWhite V. Racist
0
Q: PLE in Postgres

aqisIs there any analog of MS SQL Server PLE (Page Life Expectancy) metric in Postgres? I know only about cache hit ratio, which request look like: select sum(blks_hit)*100/sum(blks_hit+blks_read) as hit_ratio from pg_stat_database; However, I need to understand which request is consuming ...

I think this ^ was wrongfully closed.
@JoshDarnell That's more about when logging starts though. I'm talking about an SI snapshot being set when reading.
Looks answerable to me, after Hannah's edit
@mustaccio Ironically, it was your comment that convinced me it needed clarification
This is a great example of an X-Y Problem -- instead of asking how to achieve your goal you suggest an incorrect approach to achieving it and ask why it doesn't work. So, what is it that you are trying to achieve? — mustaccio 5 hours ago
Right, but the edit was made 3 hours before the closure
16:20
Right but there were seven other comments and one not even in English
It’s also interesting to consider how things turn out if you read data into a temp table and then use that as the modification filter
RCSI and SI can get bamboozled
@ErikDarling Doing cross-database stuff isn't technically supported under row-versioning isolation levels IIRC
Hornswoggled
@PaulWhite heh heh heh
@PaulWhite so there are three start times for a tran. The BEGIN TRAN time, the first statement (SI start point) and the first write statement (logging start). ...
Gracias
16:23
@ypercubeᵀᴹ Yeah, though the BEGIN TRAN time doesn't really count for anything
which of the three would GETDATE() be?
@ypercubeᵀᴹ impossible for anyone who cares deeply about isolation levels
Well, versions aren't times, but GETDATE() is a runtime constant set when the containing statement starts. It would be different for each statement (non-inline functions aside)
OTOH if you have multiple GETDATE()s in a single query you can get different constants
Databases were a mistake
oh, it's statement time, not transaction. ok
There is a function for statement/transaction start time, but it's internal-only and not implemented in T-SQL
Shame, because it would be useful
16:28
Have you considered opening a First Party User Voice item?
Good god no
Actually, there might be one
But I didn't create it
That’s why it hasn’t been implemented
I suppose I shouldn't say it isn't implemented. It is, but it's only callable from a system context
Some system proc or function has it in somewhere
Don't ask, because I don't remember
@ErikDarling Well, they started it
All done with precons and sessions now?
That was a WW2 reference btw so don't worry if you don't get it for a couple of years, being american and all
Clearly you haven't watched the History Channel in America. It is all WW2.
> During World War II, the United States began to provide significant military supplies and other assistance to the Allies in September 1940, even though the United States did not enter the war until December 1941.
Other places believe WW2 started on 1 September 1939
Expalined.
16:38
I believe it started in 1918
But that’s the benefit of hindsight
That's one way of looking at it
Very arguable
Looks like that reindeer made you smart
@PaulWhite Expalin Plan
Or maybe it was the pear
@PaulWhite Oh, right!
@JoshDarnell Well, it was a lovely link anyway so I feel bad but hey there you go
No one said it would be easy
16:42
Haha no, it's a good clarification. Ironically, a snapshot isolation query was what originally led me to write that post.
I think I did a select * from dummy or something in my snapshot piece
Who can remember these things
That's a very unfortunate execution plan.
I'm just glad Erik solved parameter sniffing through lend-lease dynamic SQL
@PaulWhite most of what I know is remembering things you’ve written
@JoshDarnell Yeah, it's a classic
16:45
Maybe you were the reindeer all along
@ErikDarling same same
I remember the days I used to remember things without writing them down.
Or I think I do.
Now that it’s part of the transcript you’ll never know
Very meta
@PaulWhite Probably not
@ErikDarling, why are you wrapping daily blog posts in the newsletter? Is it to avoid the Twitter card previews?
1 hour ago, by Paul White
Is that also available in English
17:10
That as well. But one question at a time
Does chat detect question conflicts
17:24
Maybe we need Snapchat Isolation
17:41
I like the scalar subquery as it's obvious to both humans and the Query Optimizer that the subquery must return at most one row. — David Browne - Microsoft 2 hours ago
"obvious to [...] the Query Optimizer"
And then you get that wacked out plan.
I wonder which two humans he means
 
4 hours later…
22:02
@JoshDarnell Ah I remember that question from this morning. Nice answer. 👍 Not sure why the scalar subquery throws off the engine so much other than the normal reasoning of the more complex WHERE clause being harder for it to estimate accurately, I guess.
 
2 hours later…
23:50
@JoshDarnell Don't people use a view for a single-row configuration table?

« first day (4298 days earlier)      last day (869 days later) »