Search Postgresql Archives

Partition constraints behaving strangely

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have an issue with a table partitioned by one boolean column. The query planner only seems to skip the non matching table if expired (the column I use for the partition) is true.

Here is a simple example:

CREATE TABLE mos (type_id   INTEGER UNIQUE, expired boolean);
CREATE TABLE mos_expired_1 ( CHECK ( expired = true  ) ) INHERITS (mos);
CREATE TABLE mos_active_1 ( CHECK ( expired = false ) ) INHERITS (mos);
INSERT INTO mos_expired_1 (type_id,expired) VALUES(1, true);
INSERT INTO mos_active_1 (type_id,expired) VALUES(2, false);

EXPLAIN SELECT * from mos where expired = true;

Result  (cost=0.00..66.60 rows=2330 width=5)
  ->  Append  (cost=0.00..66.60 rows=2330 width=5)
        ->  Seq Scan on mos  (cost=0.00..33.30 rows=1165 width=5)
              Filter: expired
-> Seq Scan on mos_expired_1 mos (cost=0.00..33.30 rows=1165 width=5)
              Filter: expired



EXPLAIN SELECT * from mos where expired = false;

Result  (cost=0.00..99.90 rows=3495 width=5)
  ->  Append  (cost=0.00..99.90 rows=3495 width=5)
        ->  Seq Scan on mos  (cost=0.00..33.30 rows=1165 width=5)
              Filter: (NOT expired)
-> Seq Scan on mos_expired_1 mos (cost=0.00..33.30 rows=1165 width=5)
              Filter: (NOT expired)
-> Seq Scan on mos_active_1 mos (cost=0.00..33.30 rows=1165 width=5)
              Filter: (NOT expired)

I would really like to know if I am missing something or it's a query planner issue.

--
Dominik Sander

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux