## Re: Calculation of unused columns

From: Jeff Janes pgsql-performance(at)postgresql(dot)org Re: Calculation of unused columns 2009-10-18 17:59:04 f67928030910181059g37293530t982204699829faad@mail.gmail.com (view raw or flat) 2009-10-17 22:58:16 from Volker Grabsch  2009-10-18 00:07:21 from Tom Lane   2009-10-18 01:41:34 from Tom Lane    2009-10-18 01:53:11 from Robert Haas     2009-10-18 02:19:33 from Tom Lane      2009-10-18 14:38:18 from Daniel Migowski       2009-10-18 15:59:56 from Tom Lane       2009-10-18 17:35:29 from Tim Landscheidt        2009-10-18 17:59:04 from Jeff Janes         2009-10-18 20:00:25 from Robert Haas          2009-10-18 20:54:10 from Tom Lane           2009-10-18 22:26:58 from Robert Haas            2009-10-18 23:41:38 from Tom Lane             2009-10-19 16:01:17 from Tom Lane           2009-10-19 17:54:45 from Gerhard Wiesinger            2009-10-19 18:05:27 from Tom Lane    2009-10-19 17:36:15 from Simon Riggs     2009-10-19 17:43:20 from Tom Lane      2009-10-19 17:48:58 from Simon Riggs       2009-10-19 17:58:24 from Tom Lane        2009-10-19 18:09:27 from Simon Riggs         2009-10-19 18:23:45 from Tom Lane     2009-10-19 17:48:42 from "Kevin Grittner" pgsql-performance
```On Sun, Oct 18, 2009 at 10:35 AM, Tim Landscheidt
<tim(at)tim-landscheidt(dot)de> wrote:
> Daniel Migowski <dmigowski(at)ikoffice(dot)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.

Even if country.id is a primary or unique key?

Jeff

```

### pgsql-performance by date

 Next: From: Tom Lane Date: 2009-10-18 18:20:19 Subject: Re: Full text search - query plan? PG 8.4.1 Previous: From: Tim Landscheidt Date: 2009-10-18 17:35:29 Subject: Re: Calculation of unused columns