UNION ALL has higher cost than inheritance

Поиск
Список
Период
Сортировка
От Itagaki Takahiro
Тема UNION ALL has higher cost than inheritance
Дата
Msg-id AANLkTi=hjgL=GYPumF2_Kf6DWOFLVE0rQgz-p5VFLFYn@mail.gmail.com
обсуждение исходный текст
Ответы Re: UNION ALL has higher cost than inheritance  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
I found an explicit UNION ALL has higher cost than an automatic expansion
by inheritance (49 vs. 83 in the example below). Where does the difference
come from?  Since they have almost same plan trees, should it be the same cost?

=# CREATE TABLE parent (i integer);
=# CREATE TABLE child () INHERITS (parent);
=# INSERT INTO child SELECT generate_series(1, 1000);
=# CREATE INDEX ON child (i);
=# ANALYZE;

=# EXPLAIN SELECT * FROM parent;                                QUERY PLAN
----------------------------------------------------------------------------Result  (cost=0.00..49.00 rows=3400
width=4) ->  Append  (cost=0.00..49.00 rows=3400 width=4)        ->  Seq Scan on parent  (cost=0.00..34.00 rows=2400
width=4)       ->  Seq Scan on child parent  (cost=0.00..15.00 rows=1000 width=4)
 
(4 rows)

=# EXPLAIN SELECT * FROM ONLY parent UNION ALL SELECT * FROM child;                          QUERY PLAN
----------------------------------------------------------------Append  (cost=0.00..83.00 rows=3400 width=4)  ->  Seq
Scanon parent  (cost=0.00..34.00 rows=2400 width=4)  ->  Seq Scan on child  (cost=0.00..15.00 rows=1000 width=4)
 
(3 rows)

-- 
Itagaki Takahiro


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Extensions, this time with a patch
Следующее
От: "David E. Wheeler"
Дата:
Сообщение: Re: Extensions, this time with a patch