Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XN6cC-00045U-A7 for pgsql-performance@arkaria.postgresql.org; Thu, 28 Aug 2014 20:48:16 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XN6cB-0000eK-MM for pgsql-performance@arkaria.postgresql.org; Thu, 28 Aug 2014 20:48:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XN6cA-0000eC-Ih for pgsql-performance@postgresql.org; Thu, 28 Aug 2014 20:48:14 +0000 Received: from 01.zmailcloud.com ([192.198.85.104] helo=mx-out-1.zmailcloud.com) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XN6c5-00042L-8w for pgsql-performance@postgresql.org; Thu, 28 Aug 2014 20:48:13 +0000 Received: from smtp.01.com (smtp.01.com [10.10.0.43]) by mx-out-1.zmailcloud.com (Postfix) with ESMTP id 21873564C5B for ; Thu, 28 Aug 2014 15:48:07 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by smtp-out-2.01.com (Postfix) with ESMTP id 137176049E for ; Thu, 28 Aug 2014 15:48:07 -0500 (CDT) X-Virus-Scanned: amavisd-new at smtp-out-2.01.com Received: from smtp.01.com ([127.0.0.1]) by localhost (smtp-out-2.01.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TtOvLm9GSh_b for ; Thu, 28 Aug 2014 15:48:07 -0500 (CDT) Received: from smtp.01.com (localhost [127.0.0.1]) by smtp-out-2.01.com (Postfix) with ESMTP id E28516049F for ; Thu, 28 Aug 2014 15:48:06 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by smtp-out-2.01.com (Postfix) with ESMTP id C2B896049E for ; Thu, 28 Aug 2014 15:48:06 -0500 (CDT) X-Virus-Scanned: amavisd-new at smtp-out-2.01.com Received: from smtp.01.com ([127.0.0.1]) by localhost (smtp-out-2.01.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id sLpsLZPWSlEo for ; Thu, 28 Aug 2014 15:48:06 -0500 (CDT) Received: from [172.47.23.104] (70-36-143-82.dsl.dynamic.sonic.net [70.36.143.82]) by smtp-out-2.01.com (Postfix) with ESMTPSA id 212AD604A5 for ; Thu, 28 Aug 2014 15:48:06 -0500 (CDT) Message-ID: <53FF9585.2020503@agliodbs.com> Date: Thu, 28 Aug 2014 13:48:05 -0700 From: Josh Berkus Organization: PostgreSQL Experts Inc. User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Performance issue: index not used on GROUP BY... References: <1409215840535-5816702.post@n5.nabble.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 08/28/2014 01:50 AM, gmb wrote: > Can somebody please confirm whether aggregate functions such as GROUP BY > should use indexes ? Sometimes. In your case, the index has one more column than the GROUP BY, which makes it less likely that Postgres will use it (since depending on the cardinality of ddet_id, it might actually be slower to use the index). In addition, other folks on this thread have already pointed out the memory settings issues to you. -- Josh Berkus PostgreSQL Experts Inc. http://pgexperts.com -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance