New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't generate monitoring snapshots for statements which only reference MON$DATABASE #7567
Comments
That's not as good as seems at the first glance. First of all, snapshot is created not for statement but for transaction. And nobody can guarantee that such transaction does not reference other monitoring tables later. I.e. we can have inconsistency between MON$DATABASE and other monitoring tables. |
Agree with @AlexPeshkoff. Instead of creating "short path"'s for some very special cases, we need to re-think whole monitoring architecture, imho. |
What inconsistencies are you thinking of? I don't see which data in MON$DATABASE could become inconsistent with other monitoring tables. |
On 5/5/23 18:48, Mark Rotteveel wrote:
That's not as good as seems at the first glance. First of all,
snapshot is created not for statement but for transaction. And
nobody can guarantee that such transaction does not reference
other monitoring tables later. I.e. we can have inconsistency
between MON$DATABASE and other monitoring tables.
What inconsistencies are you thinking of? I don't see which data in
MON$DATABASE could become inconsistent with other monitoring tables.
For example transaction with next transaction number may arrive in
mon$transactions.
|
Transaction and attachment numbers. +1 for rethinking whole system. IMHO, monitoring tables must be dirty read (may be with cursor stability), i.e. formed at the moment the request access them. |
I can't come up with a scenario where that would result in an inconsistency or a problem. I think it would be an acceptable risk. |
Maybe better add alias for call of. |
On 5/5/23 18:59, Mark Rotteveel wrote:
For example transaction with next transaction number may arrive in
mon$transactions.
I can't come up with a scenario where that would result in an
inconsistency or a problem. I think it would be an acceptable risk.
May be better go other way not adding any risk, even one that appears
acceptable from first POV? And do not limit ourself if we will want/need
to add more data to monitoring.
There are many other ways to solve mon$ performance problem - for
example explicit session control statement to switch mon$ tables into
statement (i.e. cursor) stability mode? That's just first idea that came
to my mind.
|
I don't mind rethinking the original idea. Just want to mention two points that caused the snapshot being transaction-level.
That said, I don't mind having both consistency options (transaction-level and statement-level) available, let's just define how it should be controlled by users. |
I also consider new session control statements as a way to go. For the beginning: things that could be managed:
|
And they aren't? I was sure that ID is attachment_id and it is stable during attachment lifetime. The same for transactions and statements. Also I cannot say for everybody but if the attachment has disappeared at the moment when I query IO_STATS, it is fine for me to get nothing. |
You misunderstud ticket. It is for changing MON$DATABASE to not get whole monitoring snapshot. |
Yes, and I would like to hear how this inconsistency in IDs can appear if these IDs are stable during whole object's lifetime, not just for monitoring snapshot. |
Attachment/transaction/statement IDs are stable. But MON$*_STATS tables have an artificial primary key which is globally unique in the shared memory but remapped to snapshot-level artificial IDs when snapshot is created, so two different snapshots may have two different IDs for the same object. |
Snapshot scope is meaningless for statement-level snapshots, as we already know all tables accessed by the statement. And while I agree that we could control that scope for transaction-level snapshots, I'm not really sure this is needed. If we expect the dynamically extended snapshot (with tables loaded by demand) being possibly inconsistent between its tables, then user may just use statement-level snapshot with the same side effects. The only useful usage case that comes to mind is when user wants to get the small snapshot ASAP (without loading huge mon$compiled_statements, for example) and will query this snapshot later in the same transaction which also must be fast. I dunno how common this is in practice. |
Why not simply link the scope of the snapshot to the isolation level of the transaction? Read committed snapshot at the statement level, snapshot - at the transaction level. |
It's also an option, but what if someone need to use a different snapshot level than its transaction (which is generally unknown inside a procedure)? Using an autonomous transaction could help, but only if it allows to override the parent transaction options which AFAIK is currently impossible (although IMO should be supported). |
Always using autonomous transaction (even with ability to change
isolation) is also not always good - this breaks an ability to use
permanent snapshot of parent RC transaction, which works now.
|
Currently, referencing any monitoring table will generate a monitoring snapshot. This is a relatively costly operation, and it should be unnecessary for queries which only reference the MON$DATABASE monitoring table.
Excluding MON$DATABASE from generating a monitoring table should make it cheaper to use that table.
The text was updated successfully, but these errors were encountered: