Re: BUG #1435: Optimizer not using index on large tables when inner joining two views - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #1435: Optimizer not using index on large tables when inner joining two views
Date
Msg-id 25577.1106605263@sss.pgh.pa.us
Whole thread Raw
In response to BUG #1435: Optimizer not using index on large tables when inner joining two views  ("Yary Hluchan" <not.com@gmail.com>)
List pgsql-bugs
"Yary Hluchan" <not.com@gmail.com> writes:
> My reading of it is that the optimizer isn't applying a distributive rule:
> condition(a union b) == condition(a) union condition(b).

No, the correct reading is that a UNION subquery is planned
independently of the surrounding query.  This is not likely to change
soon, as it would involve some rather wholesale changes.

My advice is to lose the open/closed distinction and fold those tables
into single tables with an extra boolean flag column.  I suppose the
point of this database layout is to provide fast access to the "open"
subsets, but you could probably achieve that by making partial indexes,
eg

    create index vote_open_ids on vote (id) where is_open;

            regards, tom lane

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #1433: domain check constraint not checked when adding new column
Next
From: Martin Pitt
Date:
Subject: Insecure temporary file usage in developer/build tools