pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re[2]: LISTEN/NOTIFY ultra slow speed
2+ messages / 2 participants
[nested] [flat]

* Re[2]: LISTEN/NOTIFY ultra slow speed
@ 2022-03-15 10:39  Арсен Арутюнян <arutar@bk.ru>
  0 siblings, 1 reply; 2+ messages in thread

From: Арсен Арутюнян @ 2022-03-15 10:39 UTC (permalink / raw)
  To: pgsql-general; +Cc: tgl@sss.pgh.pa.us


i looked at the file "\src\backend\commands\async.c"
there is a check for duplicate messages
 
/******** PG 10
if (AsyncExistsPendingNotify(channel, payload))
return;
***********/
 
/******** PG 13
if (AsyncExistsPendingNotify(n))
{
…...
}
***********/
Is this slowdown related to this check?
Is it possible to skip the check if I'm absolutely sure the message is unique?
 
 
--
Arsen Arutyunyan
 
  
>Вторник, 15 марта 2022, 10:34 +03:00 от Арсен Арутюнян <arutar@bk.ru>:
> 
> 
>1)
>select version();
>                          version
>------------------------------------------------------------
> PostgreSQL 10.6, compiled by Visual C++ build 1800, 64-bit
> 
>2) $PGDATA/pg_notify/
>Sometimes this folder is empty, sometimes it contains the file I have attached. The file is always less than 200kb
> 
> 
>--
>Arsen Arutyunyan
> 
> 
>>Понедельник, 14 марта 2022, 15:53 +03:00 от Арсен Арутюнян < arutar@bk.ru >:
>> 
>>    Hello! I'm having trouble with LISTEN/NOTIFY speed. Now I have about 100-200 (few?) clients who are actively messaging. But recently I started to notice a drop in speed. Changing the log_min_duration_statement parameter did not show slow queries in the log.
>>    As it turned out, the pg_notify(text ,text) function
>>          or the
>>          NOTIFY text, 'text' queries takes an extremely long time (0.7-1.5sec),
>>    but the select pg_notification_queue_usage() query always returns 0.
>>Please tell me what's the matter, where did I make a mistake? 
>>What needs to be done to increase the speed of adding to the message queue?
>> 
>>--
>>Arsen Arutyunyan
>|What PG version is this exactly?  What is in $PGDATA/pg_notify/ ?
>|            regards, tom lane
> 
 

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Re[2]: LISTEN/NOTIFY ultra slow speed
@ 2022-03-15 14:32  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Арсен Арутюнян <arutar@bk.ru>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2022-03-15 14:32 UTC (permalink / raw)
  To: Арсен Арутюнян <arutar@bk.ru>; +Cc: pgsql-general

=?UTF-8?B?0JDRgNGB0LXQvSDQkNGA0YPRgtGO0L3Rj9C9?= <arutar@bk.ru> writes:
> i looked at the file "\src\backend\commands\async.c"
> there is a check for duplicate messages

Yup.

> Is this slowdown related to this check?

[ shrug... ]  You've provided no evidence either for or against that
possibility.

It seems a little unlikely that you could have a lot of pending messages
without also seeing data accumulating in pg_notify/, but on the other hand
it's also hard to think of other places that time could be getting spent
if the queue is always empty.  Can you use perf(1) or some such tool to
try to identify where the time is being spent?  There's some advice
about that here:

https://wiki.postgresql.org/wiki/Profiling_with_perf

> Is it possible to skip the check if I'm absolutely sure the message is unique?

Not a good idea.  You could upgrade to PG 13 or later, where that
code has been improved.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2022-03-15 14:32 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-03-15 10:39 Re[2]: LISTEN/NOTIFY ultra slow speed Арсен Арутюнян <arutar@bk.ru>
2022-03-15 14:32 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox