Re: Calculation of unused columns - Mailing list pgsql-performance

From Tim Landscheidt
Subject Re: Calculation of unused columns
Date
Msg-id m3my3oppum.fsf@passepartout.tim-landscheidt.de
Whole thread Raw
In response to Calculation of unused columns  (Volker Grabsch <vog@notjusthosting.com>)
Responses Re: Calculation of unused columns  (Jeff Janes <jeff.janes@gmail.com>)
List pgsql-performance
Daniel Migowski <dmigowski@ikoffice.de> wrote:

> I have a very common example which would illustrate the
> above problem a bit more. Guess the following view on a
> company table, which references the country of that company
> in another table. The view itself just returns the
> company-id and the country-name,

>    create view companys_and_countries as
>    select company.id, country.name from company left join
> country on (company.country_id = country.id);

> Pleaso note we have a left join here, so the contents of
> country do by no means affect the contents of the "id" row
> in that view. Lets see what happens when we just query for
> the ids:

>    explain select id from companys_and_countries;

> The join is done anyway, even if its removed (At least on
> Postgres 8.3). [...]

How could that be done otherwise? PostgreSQL *must* look at
country to determine how many rows the left join produces.

Tim

pgsql-performance by date:

Previous
From: Jesper Krogh
Date:
Subject: Full text search - query plan? PG 8.4.1
Next
From: Jeff Janes
Date:
Subject: Re: Calculation of unused columns