Re: [PATCH]: Not to invaldiate CatalogSnapshot for local invalidation messages
От | Xiaoran Wang |
---|---|
Тема | Re: [PATCH]: Not to invaldiate CatalogSnapshot for local invalidation messages |
Дата | |
Msg-id | CAGjhLkO8u3VFNaL7cj49yzOLbzGjgs_S1D9EKu2DpHaQNO55DQ@mail.gmail.com обсуждение исходный текст |
Ответ на | [PATCH]: Not to invaldiate CatalogSnapshot for local invalidation messages (Xiaoran Wang <fanfuxiaoran@gmail.com>) |
Ответы |
Re: [PATCH]: Not to invaldiate CatalogSnapshot for local invalidation messages
|
Список | pgsql-hackers |
I would like to give more details of my patch.
In postgres, it uses a global snapshot “CatalogSnapshot” to check catalog data visibility.
“CatalogSnapshot” is always updated to the latest version to make the latest catalog table
content visible.
If there is any updating on catalog tables, to make the changes to be visible for the following
commands in the current transaction,
“CommandCounterIncrement”-
>”AtCCI_LocalCache”
->”CommandEndInvalidationMessages
”->”LocalExecuteInvalidationMessage”
->”InvalidateCatalogSnapshot”
it will invalidate the “CatalogSnapshot” by setting it to NULL. And next time, when it needs the
“CatalogSnapsthot” and finds it is NULL, it will regenerate one.
In a query, “CommandCounterIncrement” may be called many times, and “CatalogSnapsthot” may be
destroyed and recreated many times. To reduce such overhead, instead of invalidating “CatalogSnapshot”
, we can keep it and just increase the “curcid” of it.
When the transaction is committed or aborted, or there are catalog invalidation messages from other
backends, the “CatalogSnapshot” will be invalidated and regenerated. Sometimes, the “CatalogSnapshot” is
not the same as the transaction “CurrentSnapshot”, but we can still update the CatalogSnapshot’s
“curcid”, as the “curcid” only be checked when the tuple is inserted or deleted by the current transaction.
Hi hackers,
For local invalidation messages, there is no need to call
`InvalidateCatalogSnapshot` to set the CatalogSnapshot to NULL andrebuild it later. Instead, just update the CatalogSnapshot's `curcid`in `SnapshotSetCommandId`, this way can make the CatalogSnapshot workwell too.This optimization can reduce the overhead of rebuilding CatalogSnapshotafter each command.
Best regards, xiaoran
В списке pgsql-hackers по дате отправления: