pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Pflug <Andreas.Pflug@web.de>
To: pgsql-performance@postgresql.org
Subject: inefficient query plan with left joined view
Date: Tue, 28 Jan 2003 17:50:58 +0100
Message-ID: <3E36B4F2.1020506@web.de> (raw)

What I'm doing on V7.3.1:

select t1.keycol, t2.keycol
  from  tab1 t1
  LEFT join myview t2 on t1.keycol=t2.keycol
where t1.keycol=1000001

t1 has 100 rows, t2 has 4000, both with keycol as PK.

the view is created as
CREATE myview AS SELECT keycol, 22::integer as calc_col FROM tab2

The query plan will show an ugly subquery scan on all tab2 rows. If the 
view is created without calculated columns, the query plan looks as 
expected showing and index scan on tab2 with the correct condition, 
inner join will always be ok.

In real life, the view consists of a lot more tables, and the tables may 
contain >1,000,000 rows so you may imagine the performance...





view thread (4+ messages)  latest in thread

Message-ID: <3E36B4F2.1020506@web.de>
Permalink:  ../3E36B4F2.1020506@web.de/
Also on:    postgresql.org/message-id/3E36B4F2.1020506@web.de

 · 

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-performance@postgresql.org
  Cc: Andreas.Pflug@web.de
  Subject: Re: inefficient query plan with left joined view
  In-Reply-To: <3E36B4F2.1020506@web.de>
  References: <3E36B4F2.1020506@web.de>

* 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