X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D7684DB077 for ; Thu, 27 Oct 2005 19:52:25 -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 71237-09 for ; Thu, 27 Oct 2005 22:52:23 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id 728A5DB06F for ; Thu, 27 Oct 2005 19:52:24 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id B4EB21529A; Thu, 27 Oct 2005 17:52:27 -0500 (CDT) Date: Thu, 27 Oct 2005 17:52:27 -0500 From: "Jim C. Nasby" To: Michael Best Cc: pgsql-performance@postgresql.org Subject: Re: how postgresql request the computer resources Message-ID: <20051027225227.GT63747@pervasive.com> References: <4360F8C1.4040202@archonet.com> <43614D9F.9010600@pendragon.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <43614D9F.9010600@pendragon.org> X-Operating-System: FreeBSD 4.11-RELEASE-p10 i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.008 required=5 tests=[AWL=0.008] X-Spam-Score: 0.008 X-Spam-Level: X-Archive-Number: 200510/436 X-Sequence-Number: 15204 On Thu, Oct 27, 2005 at 03:58:55PM -0600, Michael Best wrote: > Richard Huxton wrote: > >>WITH ANY OF THIS QUERIES MSSQL TAKES NOT MUCH OF 7 SECONDS.... > > > > > >In which case they make a bad choice for showing PostgreSQL is faster > >than MSSQL. Is this the only query you have, or are others giving you > >problems too? > > > >I think count(*) is about the weakest point in PG, but I don't think > >there'll be a general solution available soon. As I'm sure someone has > >mentioned, whatever else, PG needs to check the row for its visibility > >information. > > > > From the start of your email, you seem to suspect your configuration > >needs some work. Once you are happy that your settings in general are > >good, you can override some by issuing set statements before your query. > >For example: > > SET work_mem = 10000; > >might well improve example #2 where you had a hash. > > > >-- > > Richard Huxton > > Archonet Ltd > > Someone had suggested keeping a vector table with +1 and -1 for row > insertion and deletion and then running a cron to sum the vectors and > update a table so that you could select from that table to get the row > count. Perhaps some sort of SUM() on a column function. > > Since this seems like a reasonable approach (or perhaps there may be yet > another better mechanism), cannot someone add this sort of functionality > to Postgresql to do behind the scenes? There's all kinds of things that could be added; the issue is ascertaining what the performance trade-offs are (there's no such thing as a free lunch) and if the additional code complexity is worth it. Note that your suggestion probably wouldn't work in this case because the user isn't doing a simple SELECT count(*) FROM table;. I'd bet that MSSQL is using index covering to answer his queries so quickly, something that currently just isn't possible with PostgreSQL. But if you search the -hackers archives, you'll find a discussion on adding limited heap tuple visibility information to indexes. That would allow for partial index covering in many cases, which would probably be a huge win for the queries the user was asking about. -- Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com Pervasive Software http://pervasive.com work: 512-231-6117 vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461