X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E663D52B0D for ; Thu, 14 Jul 2005 20:42:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 28191-06 for ; Thu, 14 Jul 2005 23:42:14 +0000 (GMT) Received: from ash25e.internode.on.net (ash25e.internode.on.net [203.16.214.182]) by svr1.postgresql.org (Postfix) with ESMTP id 09BDD52B5B for ; Thu, 14 Jul 2005 20:42:12 -0300 (ADT) Received: from pluto.mirrabooka.com (ppp188-133.static.internode.on.net [150.101.188.133]) by ash25e.internode.on.net (8.12.9/8.12.6) with ESMTP id j6ENgDEa061538 for ; Fri, 15 Jul 2005 09:12:14 +0930 (CST) (envelope-from alison@mirrabooka.com) Received: by pluto.mirrabooka.com (Postfix, from userid 506) id A6D522B11E; Fri, 15 Jul 2005 09:42:12 +1000 (EST) Date: Fri, 15 Jul 2005 09:42:12 +1000 To: pgsql-performance@postgresql.org Subject: Re: lots of updates on small table Message-ID: <42D6F854.nail3K81VIICH@pluto.mirrabooka.com> References: <42D5F34E.nail9QE1195IE@pluto.mirrabooka.com> <20050714162114.GA19778@alvh.no-ip.org> In-Reply-To: <20050714162114.GA19778@alvh.no-ip.org> User-Agent: nail 11.6 9/7/04 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit From: alison@mirrabooka.com (Alison Winters) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200507/195 X-Sequence-Number: 13436 Hi, > > Our application requires a number of processes to select and update rows > > from a very small (<10 rows) Postgres table on a regular and frequent > > basis. These processes often run for weeks at a time, but over the > > space of a few days we find that updates start getting painfully slow. > > We are running a full vacuum/analyze and reindex on the table every day, > Full vacuum, eh? I wonder if what you really need is very frequent > non-full vacuum. Say, once in 15 minutes (exact rate depending on dead > tuple rate.) > Is there a difference between vacuum and vacuum full? Currently we have a cron job going every hour that does: VACUUM FULL VERBOSE ANALYZE plc_fldio REINDEX TABLE plc_fldio The most recent output was this: INFO: --Relation public.plc_fldio-- INFO: Pages 1221: Changed 3, reaped 256, Empty 0, New 0; Tup 108137: Vac 4176, Keep/VTL 108133/108133, UnUsed 19, MinLen 84, MaxLen 84; Re-using: Free/Avail. Space 445176/371836; EndEmpty/Avail. Pages 0/256. CPU 0.04s/0.14u sec elapsed 0.18 sec. INFO: Index plcpage_idx: Pages 315; Tuples 108137: Deleted 4176. CPU 0.03s/0.04u sec elapsed 0.14 sec. INFO: Rel plc_fldio: Pages: 1221 --> 1221; Tuple(s) moved: 0. CPU 0.03s/0.04u sec elapsed 0.36 sec. INFO: Analyzing public.plc_fldio VACUUM REINDEX We'll up it to every 15 minutes, but i don't know if that'll help because even with the current vacuuming the updates are still getting slower and slower over the course of several days. What really puzzles me is why restarting the processes fixes it. Does PostgreSQL keep some kind of backlog of transactions all for one database connection? Isn't it normal to have processes that keep a single database connection open for days at a time? Regarding the question another poster asked: all the transactions are very short. The table is essentially a database replacement for a shared memory segment - it contains a few rows of byte values that are constantly updated byte-at-a-time to communicate data between different industrial control processes. Thanks for the thoughts everyone, Alison