(2010/01/26 1:11), Bernd Helmle wrote:
> --On 25. Januar 2010 11:39:21 +0900 KaiGai Kohei <kaigai(at)ak(dot)jp(dot)nec(dot)com>
>> (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) | 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
> 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;
> 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
Hmm... I also could observe similar result in 4 times iteration of
ALTER TABLE with your test_rename.sql.
I agree the recent V4 patch is poor in performance perspective.
* CVS HEAD
* Rcent V4 patch:
* Previous V3 patch:
The V3 patch is designed to compute an expected inhcount for each relations
to be altered at first, then it shall be compared to pg_attribute.inhcount
to be renamed.
Basically, its execution cost is same order except for a case when a relation
has diamond inheritance tree.
The find_all_inheritors() does not check child relations which is already
scanned. However, in this case, we have to check how many times is the child
relation inherited from a common origin.
I guess it is reason of the different between -HEAD and V3.
For example, if we have the following inheritance tree,
/ \ \
\ / \
A3 -- A6
The find_all_inheritors() checks existence of directly inherited relations
at A1, ... , A6 without any duplications, because this function does not
intend to compute how many times was it inherited.
The find_all_inheritors_with_inhcount() in V3 patch checks existence of
directly inherited relations, even if the target relation is already checked,
because it also has to return the times to be inherited from a common origin.
In this example, it considers the above structure is same as the following
tree. In this diagram, we can find A4 and A5 twice, and A6 thrice.
A2 - A4 - A6
A3 - A4 - A6
Thus, the test_rename.sql was the worst case test for V3 also.
However, I don't think we should keep the bug in the next release.
The CVS HEAD's performance is the result of omission for necessary checks.
I think we should back to the V3 patch approach, and also reconsider
the logic in ATPrepAlterColumnType().
OSS Platform Development Division, NEC
KaiGai Kohei <kaigai(at)ak(dot)jp(dot)nec(dot)com>
In response to
pgsql-hackers by date
|Next:||From: Tom Lane||Date: 2010-01-26 01:22:31|
|Subject: Re: About "Our CLUSTER implementation is pessimal" patch |
|Previous:||From: Greg Smith||Date: 2010-01-26 00:29:29|
|Subject: Re: Dividing progress/debug information in pg_standby,
and stat before copy|