pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feed From: A.Bhuvaneswaran <bhuvan@symonds.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-admin@postgresql.org
Subject: Re: Index is not used
Date: Sat, 20 Dec 2003 11:42:27 +0530
Message-ID: <1071900746.1380.57.camel@Bhuvan.bksys.co.in> (raw )
In-Reply-To: <14302.1071895143@sss.pgh.pa.us >
References: <1071894514.1380.1.camel@Bhuvan.bksys.co.in >
<14302.1071895143@sss.pgh.pa.us >
> Unsurprising. An inequality condition may require fetching many rows
> (the planner is estimating 336289 rows here...) and so an indexscan is
> not necessarily quicker. Have you compared actual runtimes with
> enable_seqscan on and off?
I did run with enable_seqscan off. You are right, the plan shows that
indexscan is not quicker. Here is the explain output.
On the other hand, i have calculated the actual runtime with
enable_seqscan on and off. The runtime is 617 secs & 623 secs
respectively. I have also attached the log details. Is there any way to
increase this speed?
regards,
bhuvaneswaran
Attachments:
explain.1.txt (text/plain, 4.2K) download
<explain>
=> set enable_indexscan = on;
SET
=> set enable_seqscan = off;
SET
=> EXPLAIN select distinct comp_code, supp_code, supp_name, buyer_code, buyer_name, item_code, revision, description, po_no, pos_no, order_date, delivery_date, reschedule_date, reschedule_qty, ordered_qty, delivered_qty, backorder_qty, stock, warehouse_code, allocated, exception, run_date from reschedule_bak where order_date = '01/04/2003';
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Unique (cost=6999.59..7123.48 rows=215 width=213)
-> Sort (cost=6999.59..7004.98 rows=2155 width=213)
Sort Key: comp_code, supp_code, supp_name, buyer_code, buyer_name, item_code, revision, description, po_no, pos_no, order_date, delivery_date, reschedule_date, reschedule_qty, ordered_qty, delivered_qty, backorder_qty, stock, warehouse_code, allocated, exception, run_date
-> Index Scan using reschedule_bak_order_date_idx on reschedule_bak (cost=0.00..6880.30 rows=2155 width=213)
Index Cond: (order_date = '01/04/2003'::date)
(5 rows)
=> EXPLAIN select distinct comp_code, supp_code, supp_name, buyer_code, buyer_name, item_code, revision, description, po_no, pos_no, order_date, delivery_date, reschedule_date, reschedule_qty, ordered_qty, delivered_qty, backorder_qty, stock, warehouse_code, allocated, exception, run_date from reschedule_bak where order_date >= '01/04/2003';
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Unique (cost=659460.84..678797.48 rows=33629 width=213)
-> Sort (cost=659460.84..660301.57 rows=336289 width=213)
Sort Key: comp_code, supp_code, supp_name, buyer_code, buyer_name, item_code, revision, description, po_no, pos_no, order_date, delivery_date, reschedule_date, reschedule_qty, ordered_qty, delivered_qty, backorder_qty, stock, warehouse_code, allocated, exception, run_date
-> Index Scan using reschedule_bak_order_date_idx on reschedule_bak (cost=0.00..587396.88 rows=336289 width=213)
Index Cond: (order_date >= '01/04/2003'::date)
(5 rows)
=>\q
</explain>
<log>
2003-12-20 10:35:10 [1558] LOG: query: set enable_seqscan = on;
2003-12-20 10:35:10 [1558] LOG: duration: 0.000458 sec
2003-12-20 10:36:57 [1558] LOG: query: select distinct comp_code, supp_code, supp_name, buyer_code, buyer_name, item_code, revision, description, po_no, pos_no, order_date, delivery_date, reschedule_date, reschedule_qty, ordered_qty, delivered_qty, backorder_qty, stock, warehouse_code, allocated, exception, run_date from reschedule_bak where order_date >= '01/04/2003';
2003-12-20 10:47:15 [1558] LOG: duration: 617.886026 sec
2003-12-20 11:11:37 [1558] LOG: query: set enable_seqscan = off;
2003-12-20 11:11:37 [1558] LOG: duration: 0.000458 sec
2003-12-20 11:11:40 [1558] LOG: query: select distinct comp_code, supp_code, supp_name, buyer_code, buyer_name, item_code, revision, description, po_no, pos_no, order_date, delivery_date, reschedule_date, reschedule_qty, ordered_qty, delivered_qty, backorder_qty, stock, warehouse_code, allocated, exception, run_date from reschedule_bak where order_date >= '01/04/2003';
2003-12-20 11:22:04 [1558] LOG: duration: 623.982111 sec
</log>
signature.asc (application/pgp-signature, 231B) download
view thread (5+ messages) latest in thread
Message-ID: <1071900746.1380.57.camel@Bhuvan.bksys.co.in>
Permalink: ../1071900746.1380.57.camel@Bhuvan.bksys.co.in/
Also on: postgresql.org/message-id/1071900746.1380.57.camel@Bhuvan.bksys.co.in
copy link · copy postgr.es
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-admin@postgresql.org
Cc: bhuvan@symonds.net, tgl@sss.pgh.pa.us
Subject: Re: Index is not used
In-Reply-To: <1071900746.1380.57.camel@Bhuvan.bksys.co.in>
References: <1071894514.1380.1.camel@Bhuvan.bksys.co.in> <14302.1071895143@sss.pgh.pa.us> <1071900746.1380.57.camel@Bhuvan.bksys.co.in>
* 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