pg.ddx.io  pgsql-students@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Amir Sehan <ean_ibnisaid@yahoo.com>
To: pgsql-students@postgresql.org <pgsql-students@postgresql.org>
Subject: index scan
Date: Wed, 20 Jun 2012 23:56:40 -0700 (PDT)
Message-ID: <1340261800.81804.YahooMailNeo@web121401.mail.ne1.yahoo.com> (raw)

Hello,

I have problem with EXPLAIN ANALYZE QUERY.
I want to change a plan node, from seq scan to index scan.
But i don't know the methode for it.

"HashAggregate  (cost=33.47..33.60 rows=13 width=1189) (actual time=156.499..156.573 rows=14 loops=1)"
"  ->  Append  (cost=1.31..31.75 rows=13 width=1189) (actual time=147.598..156.009 rows=14 loops=1)"
"        ->  Hash Join  (cost=1.31..24.24 rows=12 width=1192) (actual time=147.589..154.673 rows=12 loops=1)"
"              Hash Cond: (d.c_doctype_id = i.c_doctype_id)"
"              ->  Seq Scan on c_doctype d  (cost=0.00..4.01 rows=101 width=12) (actual time=0.195..0.986 rows=101 loops=1)"
"              ->  Hash  (cost=1.16..1.16 rows=12 width=1188) (actual time=0.366..0.366 rows=12 loops=1)"
"                    ->  Seq Scan on c_invoice i  (cost=0.00..1.16 rows=12 width=1188) (actual time=0.141..0.230 rows=12 loops=1)"
"                          Filter: (ispayschedulevalid <> 'Y'::bpchar)"
"        ->  Subquery Scan "*SELECT* 2"  (cost=1.18..7.39 rows=1 width=1149) (actual time=0.972..1.239 rows=2 loops=1)"
"              ->  Nested Loop  (cost=1.18..7.38 rows=1 width=1149) (actual time=0.940..1.189 rows=2 loops=1)"
"                    Join Filter: (i.c_invoice_id = ips.c_invoice_id)"
"                    ->  Hash Join  (cost=1.18..5.57 rows=1 width=1096) (actual time=0.630..0.778 rows=1 loops=1)"
"                          Hash Cond: (d.c_doctype_id = i.c_doctype_id)"
"                          ->  Seq Scan on c_doctype d  (cost=0.00..4.01 rows=101 width=12) (actual time=0.012..0.283 rows=101 loops=1)"
"                          ->  Hash  (cost=1.16..1.16 rows=1 width=1092) (actual time=0.081..0.081 rows=1 loops=1)"
"                                ->  Seq Scan on c_invoice i  (cost=0.00..1.16 rows=1 width=1092) (actual time=0.041..0.060 rows=1 loops=1)"
"                                      Filter: (ispayschedulevalid = 'Y'::bpchar)"
"                    ->  Seq Scan on c_invoicepayschedule ips  (cost=0.00..1.02 rows=1 width=66) (actual time=0.131..0.142 rows=2 loops=1)"
"                          Filter: (ips.isvalid = 'Y'::bpchar)"

Above is my query. The question is how to change seq scan to index scan to purpose optimize query. i.e seq scan on c_doctype_id?

Thanks,
Best Regards.

view thread (2+ messages)  latest in thread

Message-ID: <1340261800.81804.YahooMailNeo@web121401.mail.ne1.yahoo.com>
Permalink:  ../1340261800.81804.YahooMailNeo@web121401.mail.ne1.yahoo.com/
Also on:    postgresql.org/message-id/1340261800.81804.YahooMailNeo@web121401.mail.ne1.yahoo.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-students@postgresql.org
  Cc: ean_ibnisaid@yahoo.com
  Subject: Re: index scan
  In-Reply-To: <1340261800.81804.YahooMailNeo@web121401.mail.ne1.yahoo.com>
  References: <1340261800.81804.YahooMailNeo@web121401.mail.ne1.yahoo.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