select slows from 3 seconds to 30 seconds

From: Gary Stainburn <gary(dot)stainburn(at)ringways(dot)co(dot)uk>
To: pgsql-sql(at)postgresql(dot)org
Subject: select slows from 3 seconds to 30 seconds
Date: 2007-05-04 15:49:54
Message-ID: 200705041649.54193.gary.stainburn@ringways.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi folks.

I have the query below which when run takes approx 3 seconds. However when I
add the condition 'and w_ws_id = 10' onto the end changes to 30+ seconds.

Can anyone see why? I've included the explain for the long select.

select w_vin as key, w_vin, v_o_number as vista, v_status,
s_stock_no, s_customer_order,
coalesce(d.r_registration, p.r_registration, w_reg_no) as
reg_no,w_arrival,
w_updated::date,CURRENT_DATE-w_created::date as age, w_model,
w_radio_code, w_key_no, w_inspected, w_damage,
w_walon_repair,w_collect_date, w_despatch_date, w_sheet,
w_plates, w_accessories,
coalesce(p.d_des, d.d_des) as d_des,
coalesce(p.de_des, d.de_des) as de_des,
p.r_id as pdi,
d.r_id as delivery,
o.o_id, o.state
from walon
left outer join request_details p on p.t_id = 'P' and
substring(p.r_chassis from '(.{11}$)') = w_vin
left outer join request_details d on d.t_id = 'D' and
substring(d.r_chassis from '(.{11}$)') = w_vin
left outer join order_details o on
substring(o.o_vin from '(.{11}$)') = w_vin
left outer join stock s on substring(s.s_vin from '(.{11}$)') = w_vin
left outer join vista v on v.v_vin = w_vin
where w_hide = 0.

--
Gary Stainburn

This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000

Attachment Content-Type Size
explain.txt text/plain 28.0 KB

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Collin Peters 2007-05-04 21:51:00 Re: Insert into VIEW using RULE. Not possible to use nextval()?
Previous Message Richard Broersma Jr 2007-05-03 19:26:42 Re: Insert into VIEW using RULE. Not possible to use nextval()?