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 875495E40AC for ; Sun, 8 Aug 2004 05:21:52 -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 81696-06 for ; Sun, 8 Aug 2004 08:21:48 +0000 (GMT) Received: from mail.academyoflearning.ca (s64-180-138-192.bc.hsia.telus.net [64.180.138.192]) by svr1.postgresql.org (Postfix) with ESMTP id 6D6B45E3E30 for ; Sun, 8 Aug 2004 05:21:46 -0300 (ADT) Received: from [192.168.1.10] (d216-232-247-236.bchsia.telus.net [216.232.247.236]) (using SSLv3 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by mail.academyoflearning.ca (Postfix) with ESMTP id 368DC2F90E; Sun, 8 Aug 2004 01:21:19 -0700 (PDT) Subject: Re: Performance Bottleneck From: Mike Benoit To: Martin Foster Cc: pgsql-performance@postgresql.org In-Reply-To: References: <410FDC53.5080509@bigfoot.com> <4110FFF6.1030001@bigfoot.com> <1091812011.7149.25.camel@ipso.snappymail.ca> Content-Type: text/plain Date: Sun, 08 Aug 2004 01:21:17 -0700 Message-Id: <1091953277.11520.3.camel@ipso.snappymail.ca> Mime-Version: 1.0 X-Mailer: Evolution 1.5.92.1-1mdk Content-Transfer-Encoding: 7bit X-snappymail-MailScanner-Information: Please contact the ISP for more information X-snappymail-MailScanner: Found to be clean X-snappymail-MailScanner-SpamCheck: not spam, SpamAssassin (score=1.911, required 5, AWL -0.79, RCVD_IN_DYNABLOCK 2.60, RCVD_IN_SORBS 0.10) X-snappymail-MailScanner-SpamScore: s X-MailScanner-From: ipso@snappymail.ca X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200408/100 X-Sequence-Number: 7736 On Fri, 2004-08-06 at 23:18 +0000, Martin Foster wrote: > Mike Benoit wrote: > > > On Wed, 2004-08-04 at 17:25 +0200, Gaetano Mendola wrote: > > > > > >>>The queries themselves are simple, normally drawing information from one > >>>table with few conditions or in the most complex cases using joins on > >>>two table or sub queries. These behave very well and always have, the > >>>problem is that these queries take place in rather large amounts due to > >>>the dumb nature of the scripts themselves. > >> > >>Show us the explain analyze on that queries, how many rows the tables are > >>containing, the table schema could be also usefull. > >> > > > > > > If the queries themselves are optimized as much as they can be, and as > > you say, its just the sheer amount of similar queries hitting the > > database, you could try using prepared queries for ones that are most > > often executed to eliminate some of the overhead. > > > > I've had relatively good success with this in the past, and it doesn't > > take very much code modification. > > > > One of the biggest problems is most probably related to the indexes. > Since the performance penalty of logging the information needed to see > which queries are used and which are not is a slight problem, then I > cannot really make use of it for now. > > However, I am curious how one would go about preparing query? Is this > similar to the DBI::Prepare statement with placeholders and simply > changing the values passed on execute? Or is this something database > level such as a view et cetera? > Yes, always optimize your queries and GUC settings first and foremost. Thats where you are likely to gain the most performance. After that if you still want to push things even further I would try prepared queries. I'm not familiar with DBI::Prepare at all, but I don't think its what your looking for. This is what you want: http://www.postgresql.org/docs/current/static/sql-prepare.html -- Mike Benoit