Re: [BUG?] strange behavior in ALTER TABLE ... RENAME TO on inherited columns

From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: KaiGai Kohei <kaigai(at)ak(dot)jp(dot)nec(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, KaiGai Kohei <kaigai(at)kaigai(dot)gr(dot)jp>, pgsql-hackers(at)postgresql(dot)org, Thom Brown <thombrown(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Subject: Re: [BUG?] strange behavior in ALTER TABLE ... RENAME TO on inherited columns
Date: 2010-01-25 16:11:22
Message-ID: A4AED2940DEC9FD178543041@[172.26.14.62]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

--On 25. Januar 2010 11:39:21 +0900 KaiGai Kohei <kaigai(at)ak(dot)jp(dot)nec(dot)com>
wrote:

> (echo "CREATE TABLE t (a int);"
> for i in `seq 0 9`; do
> echo "CREATE TABLE s$i (b int) INHERITS(t);"
> for j in `seq 0 9`; do
> echo "CREATE TABLE v$i$j (c int) INHERITS(s$i);"
> for k in `seq 0 9`; do
> echo "CREATE TABLE w$i$j$k (d int) INHERITS(v$i$j);"
> for l in `seq 0 9`; do
> echo "CREATE TABLE x$i$j$k$l (e int) INHERITS(w$i$j$k);"
> done
> done
> done
> done) | psql test

Well, each table inherits one table in your test. In my test, I inherit
from multiple tables for each table. My script generates the following
inheritance tree (and wins a price of copy & paste ugliness, see
attachment):

A1, A2, A3, ..., Am
B1 INHERITS(A1...A10), B2 INHERITS(A1...A10, B3 INHERITS(A1...A10), ...Bn
C1 INHERITS(B1...B10), C2 INHERITS(B1...B10), ... Co
D1 INHERITS(C1...C10), ..., Dp

m = 10
n = 10
o = 10
p = 1000

Repeating this on my MacBook gives:

ALTER TABLE a1 RENAME COLUMN acol1 TO xyz;

-HEAD:

Time: 382,427 ms
Time: 375,974 ms
Time: 385,478 ms
Time: 371,067 ms
Time: 410,834 ms
Time: 386,382 ms

Recent V4 patch:

Time: 6065,673 ms
Time: 3823,206 ms
Time: 4037,933 ms
Time: 3873,029 ms
Time: 3899,607 ms
Time: 3963,308 ms

Note that you have to increase max_locks_per_transaction to run the script,
i used

pg_ctl -o '--checkpoint-segments=32 --max-locks-per-transaction=128' start

--
Thanks

Bernd

Attachment Content-Type Size
test_rename.sql application/octet-stream 2.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Aidan Van Dyk 2010-01-25 16:12:57 Re: MySQL-ism help patch for psql
Previous Message Andrew Dunstan 2010-01-25 16:09:12 Re: Miscellaneous changes to plperl [PATCH]