Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 4BC039FA5CE for ; Thu, 28 Sep 2006 17:17:27 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 24235-10 for ; Thu, 28 Sep 2006 17:17:17 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id 2C4A49FA5BF for ; Thu, 28 Sep 2006 17:17:16 -0300 (ADT) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1GT2bC-0003X3-Fz for pgsql-performance@postgresql.org; Thu, 28 Sep 2006 16:35:14 -0400 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 2868A3FAF; Thu, 28 Sep 2006 16:17:10 -0400 (EDT) Date: Thu, 28 Sep 2006 16:17:10 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: slow queue-like empty table Message-ID: <20060928201710.GF19794@phlogiston.dyndns.org> References: <20060928065631.GA28138@oppetid.no> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060928065631.GA28138@oppetid.no> User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.196 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200609/405 X-Sequence-Number: 21091 On Thu, Sep 28, 2006 at 08:56:31AM +0200, Tobias Brox wrote: > CPU 0.00s/0.00u sec elapsed 0.00 sec. > INFO: "my_queue": found 0 removable, 34058 nonremovable row versions in 185 pages ^^^^^^^ You have a lot of dead rows that can't be removed. You must have a lot of other transactions in process. Note that nobody needs to be _looking_ at those rows for them to be unremovable. The transactions just have to be old enough. > ------------------------------------------------------------------------------------------------------------------------------------------------------- > Limit (cost=0.00..0.04 rows=1 width=4) (actual time=402.525..402.525 rows=0 loops=1) > -> Index Scan using my_queue_pkey on stats_bet_queue (cost=0.00..1314.71 rows=34058 width=4) (actual time=402.518..402.518 rows=0 loops=1) I'm amazed this does an indexscan on an empty table. If this table is "hot", my bet is that you have attempted to optimise in an area that actually isn't an optimisation under PostgreSQL. That is, if you're putting data in there, a daemon is constantly deleting from it, but all your other transactions depend on knowing the value of the "unprocessed queue", the design just doesn't work under PostgreSQL. It turns out to be impossible to keep the table vacuumed well enough for high performance. A -- Andrew Sullivan | ajs@crankycanuck.ca In the future this spectacle of the middle classes shocking the avant- garde will probably become the textbook definition of Postmodernism. --Brad Holland