Optimizer issue -- bad query plan?

From: Moshe Jacobson <moshe(at)neadwerx(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Optimizer issue -- bad query plan?
Date: 2014-06-05 21:43:00
Message-ID: CAJ4CxL=XOHGFCJVjKVMEm2bhnz4Eyam3hYUFeQvSc2EPxf88sQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have the following query:

SELECT r.reset
FROM tb_reset r
LEFT JOIN tb_project pj ON pj.project = r.project
LEFT JOIN tb_location l ON l.location = r.location
LEFT JOIN tb_program pg ON pg.program = r.program
LEFT JOIN tb_reset_survey rsv ON rsv.reset = r.reset
LEFT JOIN tb_program_location pl ON pl.program = r.program AND
pl.location = r.location
LEFT JOIN tb_program_type pgt ON pgt.program_type = pg.program_type
LEFT JOIN tb_project_department pd ON pd.project = pj.project
LEFT JOIN tb_department d ON d.department = pd.department
LEFT JOIN tb_fiscal_calendar fc ON fc.day = r.execution_date
LEFT JOIN tb_fiscal_month fm ON fm.fiscal_month = fc.month
LEFT JOIN tb_rollout_schedule rs ON rs.fiscal_week = fc.week AND
rs.fiscal_year = fc.year AND rs.program = r.program
LEFT JOIN tb_reset_team rt ON rt.reset_team = r.reset_team
LEFT JOIN tb_vendor v ON v.vendor = rt.vendor
LEFT JOIN tb_reset_status rst ON rst.reset_status = r.reset_status
LEFT JOIN tb_order_location ol ON ol.location = r.location
LEFT JOIN tb_entity_reset er ON er.reset = r.reset
LEFT JOIN tb_market m ON m.market = l.market
LEFT JOIN tb_district dist ON dist.district = l.district
LEFT JOIN tb_mregion mr ON mr.mregion = l.mregion
LEFT JOIN tb_region rg ON rg.region = l.region
LEFT JOIN tb_ogrp ogrp ON ogrp.ogrp = l.ogrp
LEFT JOIN tb_buying_office byo ON byo.buying_office = l.buying_office
LEFT JOIN tb_project_participant pp ON pp.project = r.project
LEFT JOIN tb_project_status ps ON ps.project_status = pj.project_status
LEFT JOIN tb_entity_location el_mem ON el_mem.location = r.location
AND el_mem.role = 30
LEFT JOIN tb_entity_reset er_fcpm ON er_fcpm.reset = r.reset AND
er_fcpm.role = 74
LEFT JOIN tb_entity_location el_fss ON el_fss.location = r.location
AND el_fss.role = 35
LEFT JOIN tb_project_participant pp_ipm ON pp_ipm.project =
r.project AND pp_ipm.role = 3where r.in_scope is trueand r.project =
18922group by r.resetorder by r.reset
limit 100 offset 0;

The EXPLAIN ANALYZE for this query indicates that all of the tables in the
query are being joined despite the fact that they are not needed at all.

Why is this?

Moshe Jacobson
Manager of Systems Engineering, Nead Werx Inc. <http://www.neadwerx.com>
2323 Cumberland Parkway · Suite 201 · Atlanta, GA 30339

“Quality is not an act, it is a habit.” — Aristotle

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2014-06-05 22:09:44 Re: Optimizer issue -- bad query plan?
Previous Message Ray Stell 2014-06-05 21:07:39 Re: screwed up authentication