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 750C65342F for ; Thu, 24 Mar 2005 20:13:15 +0000 (GMT) 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 52473-08 for ; Thu, 24 Mar 2005 20:13:05 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.204]) by svr1.postgresql.org (Postfix) with ESMTP id 8640153433 for ; Thu, 24 Mar 2005 20:13:05 +0000 (GMT) Received: by rproxy.gmail.com with SMTP id a36so1006082rnf for ; Thu, 24 Mar 2005 12:13:06 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:reply-to:from:to:cc:subject:date:mime-version:content-type:content-transfer-encoding:x-mailer:in-reply-to:thread-index:x-mimeole:message-id; b=RFHhwPJygOkpro+kKgIvvma0CwpY2Ca+HaRf2RNvFmpuzHiZ0NcBqub9h7mI/0jeTt3IfUEg5tOAKhz13uyAJiNSbLG0lkU7XCDnAe9lnhLEpLPOdBWxd3XLpVeFfCRpJiIKNAXp+KPpluNPexhb9Ay+RBz7aJFGWpptscIRY8U= Received: by 10.39.2.36 with SMTP id e36mr1538448rni; Thu, 24 Mar 2005 12:13:06 -0800 (PST) Received: from MATTSPC ([12.216.69.41]) by mx.gmail.com with ESMTP id k4sm671136rnd.2005.03.24.12.13.06; Thu, 24 Mar 2005 12:13:06 -0800 (PST) Reply-To: From: "Matthew Nuzum" To: "'Tom Lane'" Cc: Subject: Re: Preventing query from hogging server Date: Thu, 24 Mar 2005 14:13:01 -0600 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.6353 In-Reply-To: <5246.1111694535@sss.pgh.pa.us> Thread-Index: AcUwrGIzF4GD3amnTLaSi/voC0d0ggAAJGmg X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Message-ID: <42431f52.4700af57.2963.ffffe2b8@mx.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.304 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200503/520 X-Sequence-Number: 11225 > I would strongly suggest doing the min and max calculations together: > > select groupid, min(col), max(col) from ... > > because if you do them in two separate queries 90% of the effort will be > duplicated. > > regards, tom lane Thanks. Other than avoiding using too much sort mem, is there anything else I can do to ensure this query doesn't starve other processes for resources? Doing the explain analyze only increases my server load by 1 and seems to readily relinquish CPU time, but previously when I had been running a test query my server load rose to unacceptable levels. FWIW, the explain was run from psql running on the db server, the test query the other day was run from one of the webservers. Should I run this on the db server to minimize load? -- Matthew Nuzum www.followers.net - Makers of "Elite Content Management System" View samples of Elite CMS in action by visiting http://www.followers.net/portfolio/