Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbb5ae8f

Browse files
committed
Use a hash table to de-duplicate NOTIFY events faster.
Previously, async.c got rid of duplicate notifications by scanningthe list of pending events to compare each one to the proposed newevent. This works okay for very small numbers of distinct events,but degrades as O(N^2) for many events. We can improve matters byusing a hash table to probe for duplicates. So as not to add alot of overhead for the simple cases that the code did handle wellbefore, create the hash table only once a (sub)transaction hasqueued more than 16 distinct notify events.A downside is that we now have to do per-event work to propagatea successful subtransaction's notify events up to its parent.(But this isn't significant unless the subtransaction had manyevents, in which case the O(N^2) behavior would have been inplay already, so we still come out ahead.)We can make some lemonade out of this lemon, though: since we mustexamine each event anyway, it's now possible to de-duplicate eventsfully, rather than skipping that for events merged up fromsubtransactions. Hence, remove the old weasel wording in notify.sgmlabout whether de-duplication happens or not, and adjust the testcase in async-notify.spec that exhibited the old behavior.While at it, rearrange the definition of struct Notification to makeit more compact and require just one palloc per event, rather thantwo or three. This saves space when there are a lot of events,in fact more than enough to buy back the space needed for the hashtable.Patch by me, based on discussions around a different patchsubmitted by Filip Rembiałkowski.Discussion:https://postgr.es/m/17822.1564186806@sss.pgh.pa.us
1 parent45aaaa4 commitbb5ae8f

File tree

3 files changed

+250
-89
lines changed

3 files changed

+250
-89
lines changed

‎doc/src/sgml/ref/notify.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ NOTIFY <replaceable class="parameter">channel</replaceable> [ , <replaceable cla
9494
</para>
9595

9696
<para>
97-
If the same channel name is signaled multiple timesfrom the same
98-
transaction with identical payload strings, the
99-
database server can decide todeliver a single notification only.
97+
If the same channel name is signaled multiple timeswith identical
98+
payload strings within the same transaction, only one instance of the
99+
notification event is delivered tolisteners.
100100
On the other hand, notifications with distinct payload strings will
101101
always be delivered as distinct notifications. Similarly, notifications from
102102
different transactions will never get folded into one notification.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp