X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 1B31E30F644 for ; Tue, 24 Jun 2003 12:16:17 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 99173-08 for ; Tue, 24 Jun 2003 09:16:06 -0300 (ADT) Received: from mwinf0302.wanadoo.fr (smtp6.wanadoo.fr [193.252.22.28]) by svr1.postgresql.org (Postfix) with ESMTP id 2E92A30F684 for ; Tue, 24 Jun 2003 09:16:06 -0300 (ADT) Received: from Paris (unknown [81.49.7.47]) by mwinf0302.wanadoo.fr (SMTP Server) with ESMTP id 30CD5C0002C1; Tue, 24 Jun 2003 14:16:03 +0200 (CEST) Reply-To: From: "Michael Mattox" To: "Richard Huxton" , Subject: Re: Performance advice Date: Tue, 24 Jun 2003 14:16:09 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) In-Reply-To: <200306241233.42361.dev@archonet.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal X-Archive-Number: 200306/141 X-Sequence-Number: 2225 > Don't log your monitoring info directly into the database, log > straight to one > or more text-files and sync them every few seconds. Rotate the > files once a > minute (or whatever seems suitable). Then have a separate process > that reads > "old" files and processes them into the database. > > The big advantage - you can take the database down for a short > period and the > monitoring goes on. Useful for those small maintenance tasks. This is a good idea but it'd take a bit of redesign to make it work. here's my algorithm now: - Every 10 seconds I get a list of monitors who have nextdate >= current time - I put the id numbers of the monitors into a queue - A thread from a thread pool (32 active threads) retrieves the monitor from the database from its id, updates the nextdate timestamp, executes the monitor, and stores the status in the database So I have two transactions, one to update the monitor's nextdate and another to update its status. Now that I wrote that I see a possibility to steamline the last step. I can wait until I update the status to update the nextdate. That would cut the number of transactions in two. Only problem is I have to be sure not to add a monitor to the queue when it's currently executing. This shouldn't be hard, I have a hashtable containing all the active monitors. Thanks for the suggestion, I'm definitely going to give this some more thought. Michael