BUG #2080: Partitioning does not work with PREPARE

From: "Janko Richter" <jankorichter(at)yahoo(dot)de>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #2080: Partitioning does not work with PREPARE
Date: 2005-11-30 17:23:45
Message-ID: 20051130172345.EC055F0B3A@svr2.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 2080
Logged by: Janko Richter
Email address: jankorichter(at)yahoo(dot)de
PostgreSQL version: 8.1
Operating system: Linux
Description: Partitioning does not work with PREPARE
Details:

Partitioning does not work with PREPARE. The following
statements show the effect:

CREATE TABLE master
(
p_id int2 NOT NULL,
PRIMARY KEY (p_id)
) WITHOUT OIDS;

CREATE TABLE partition_0
(
PRIMARY KEY (p_id),
CONSTRAINT mod CHECK ( p_id = 0::smallint )
) INHERITS (master)
WITHOUT OIDS;

CREATE TABLE partition_1
(
PRIMARY KEY (p_id),
CONSTRAINT mod CHECK ( p_id = 1::smallint )
) INHERITS (master)
WITHOUT OIDS;

INSERT INTO partition_0 VALUES (0);

INSERT INTO partition_1 VALUES (1);

EXPLAIN SELECT p_id FROM master WHERE p_id=1::smallint ;
QUERY PLAN

----------------------------------------------------------------------------
---------------------------
Result (cost=0.00..10.65 rows=2 width=2)
-> Append (cost=0.00..10.65 rows=2 width=2)
-> Index Scan using master_pkey on master (cost=0.00..4.82 rows=1
width=2)
Index Cond: (p_id = 1::smallint)
-> Index Scan using partition_1_pkey on partition_1 master
(cost=0.00..5.82 rows=1 width=2)
Index Cond: (p_id = 1::smallint)
(6 rows)

PREPARE foo(int2) AS SELECT p_id FROM master WHERE p_id=$1::smallint;
EXPLAIN EXECUTE foo(1);
QUERY PLAN
----------------------------------------------------------------------------
---------------------------
Result (cost=0.00..16.47 rows=3 width=2)
-> Append (cost=0.00..16.47 rows=3 width=2)
-> Index Scan using master_pkey on master (cost=0.00..4.82 rows=1
width=2)
Index Cond: (p_id = $1)
-> Index Scan using partition_0_pkey on partition_0 master
(cost=0.00..5.82 rows=1 width=2)
Index Cond: (p_id = $1)
-> Index Scan using partition_1_pkey on partition_1 master
(cost=0.00..5.82 rows=1 width=2)
Index Cond: (p_id = $1)
(8 rows)

Regards,
Janko Richter

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2005-11-30 17:39:24 Re: BUG #2080: Partitioning does not work with PREPARE
Previous Message Tom Lane 2005-11-30 17:11:51 Re: BUG #2075: Strange choice of bitmap-index-scan