Re: optimizing a view-driven query

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: will trillich <will(at)serensoft(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: optimizing a view-driven query
Date: 2001-03-28 23:31:38
Message-ID: 20360.985822298@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

will trillich <will(at)serensoft(dot)com> writes:
> select topic from course where course like '%comput%' ;
> -- not asking for state, we don't need to join the state table

But you still do need to join, because the join affects which rows
will be returned. The fact that you don't happen to use any values
out of one of the joined tables in your SELECT list is not very
relevant.

In this example, you might happen to know (or think you know) that there
will be one and only one state row matching any possible row from the
subjoin of the other tables, so in the end it wouldn't affect the number
of rows output. This is not an assumption the planner is prepared to
make, however.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-03-28 23:41:49 Re: Unexplained behaviour
Previous Message Tom Lane 2001-03-28 23:25:55 Re: joins and indexes -- a=b or b=a?