notify-optimisation.diff
text/x-diff
Filename: notify-optimisation.diff
Type: text/x-diff
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/backend/commands/async.c | 4 | 12 |
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 588e9f2..16c0d96 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -2160,7 +2160,6 @@ NotifyMyFrontEnd(const char *channel, const char *payload, int32 srcPid)
static bool
AsyncExistsPendingNotify(const char *channel, const char *payload)
{
- ListCell *p;
Notification *n;
if (pendingNotifies == NIL)
@@ -2175,9 +2174,11 @@ AsyncExistsPendingNotify(const char *channel, const char *payload)
* backwards in order to make duplicate-elimination a tad faster when the
* same condition is signaled many times in a row. So as a compromise we
* check the tail element first which we can access directly. If this
- * doesn't match, we check the whole list.
+ * doesn't match, we used to check the whole list; we don't do that
+ * anymore, because it was inefficient in the case when many distinct
+ * channels are notified.
*
- * As we are not checking our parents' lists, we can still get duplicates
+ * Also, as we are not checking our parents' lists, we can get duplicates
* in combination with subtransactions, like in:
*
* begin;
@@ -2192,15 +2193,6 @@ AsyncExistsPendingNotify(const char *channel, const char *payload)
strcmp(n->payload, payload) == 0)
return true;
- foreach(p, pendingNotifies)
- {
- n = (Notification *) lfirst(p);
-
- if (strcmp(n->channel, channel) == 0 &&
- strcmp(n->payload, payload) == 0)
- return true;
- }
-
return false;
}