Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T4yuG-0006WK-5q for pgsql-performance@postgresql.org; Fri, 24 Aug 2012 18:46:56 +0000 Received: from wentylator.ang.com.pl ([89.174.215.202]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T4yuE-0005z0-Bm for pgsql-performance@postgresql.org; Fri, 24 Aug 2012 18:46:55 +0000 Received: from Artur7 (cfidsl [83.18.105.226]) by wentylator.ang.com.pl (Postfix) with ESMTP id 3741C2DD2A1 for ; Fri, 24 Aug 2012 20:46:56 +0200 (CEST) From: =?iso-8859-2?Q?Artur_Zaj=B1c?= To: References: In-Reply-To: Subject: NOTIFY performance Date: Fri, 24 Aug 2012 20:46:42 +0200 Message-ID: <002401cd8228$ce80e970$6b82bc50$@ang.com.pl> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQHlceJe921BWUWzabFvedI54+GASpc5bZvA Content-Language: pl X-wentylator-MailScanner-Information: Please contact the ISP for more information X-wentylator-MailScanner: Found to be clean X-wentylator-MailScanner-SpamCheck: not spam, SpamAssassin (cached, score=0, required 6, autolearn=not spam) X-wentylator-MailScanner-From: azajac@ang.com.pl X-Spam-Status: No X-Pg-Spam-Score: 0.6 (/) X-Archive-Number: 201208/155 X-Sequence-Number: 47693 Hello, I would like to create some application using triggers and LISTEN/NOTIFY framework. I've tested it, and I noticed that performance of NOTIFY significally decreases with increasing number of distinct NOTIFIES in transaction. I found that function AsyncExistsPendingNotify is responsibe for it. I think that complexivity of searching duplicates there is O(N^2). Would be possible to improve performance of it? Maybe by using list for elements precedence and binary search tree for searching duplicates - with complexivity of O(Nlog2(N)). I'v tested with 50000 of NOTICES. Updating table with 20000 NOTICES when searching is not performed took 1,5 second. With searching it took 28 seconds. ------------------------------------------- Artur Zajac