pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: gmb <gmbouwer@gmail.com>
To: pgsql-performance@postgresql.org
Subject: Re: Performance issue: index not used on GROUP BY...
Date: Thu, 28 Aug 2014 02:08:59 -0700 (PDT)
Message-ID: <1409216939896-5816706.post@n5.nabble.com> (raw)
In-Reply-To: <CAGnEbogEvqqdwGA_jrrdt_8S3dMvvSNdT=sna8jC87nRmAW+cA@mail.gmail.com>
References: <1409215840535-5816702.post@n5.nabble.com>
	<CAGnEbogEvqqdwGA_jrrdt_8S3dMvvSNdT=sna8jC87nRmAW+cA@mail.gmail.com>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>



> Can you send `EXPLAIN (analyze, buffers)` for your query instead?
> It'll show exactly what's going on.

GroupAggregate  (cost=303425.31..339014.43 rows=136882 width=48) (actual
time=4708.181..6688.699 rows=287268 loops=1)
  Buffers: shared read=23899, temp read=30974 written=30974
  ->  Sort  (cost=303425.31..306847.34 rows=1368812 width=48) (actual
time=4708.170..5319.429 rows=1368744 loops=1)
        Sort Key: co_id, client_id, doc_no, 
        Sort Method: external merge  Disk: 80304kB
        Buffers: shared read=23899, temp read=30974 written=30974
        ->  Seq Scan on ddetail  (cost=0.00..37587.12 rows=1368812 width=48)
(actual time=0.122..492.964 rows=1368744 loops=1)
              Buffers: shared read=23899
Total runtime: 6708.244 ms


My initial attempt was this  (this is what I actually need):

SELECT  co_id ,  client_id , doc_no ,  line_id , batch_no , sum( amount  )
FROM ddetail
GROUP BY co_id ,  client_id , doc_no ,  line_id  , batch_no ;

but I removed column batch_no from the query because I thought this was the
cause of the problem ( batch_no is not part of my PK ).


Thanks 



--
View this message in context: http://postgresql.1045698.n5.nabble.com/Performance-issue-index-not-used-on-GROUP-BY-tp5816702p58167...
Sent from the PostgreSQL - performance mailing list archive at Nabble.com.


-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance



view thread (9+ messages)  latest in thread

Message-ID: <1409216939896-5816706.post@n5.nabble.com>
Permalink:  ../1409216939896-5816706.post@n5.nabble.com/
Also on:    postgresql.org/message-id/1409216939896-5816706.post@n5.nabble.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: gmbouwer@gmail.com
  Subject: Re: Performance issue: index not used on GROUP BY...
  In-Reply-To: <1409216939896-5816706.post@n5.nabble.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox