slow array(subselect)

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема slow array(subselect)
Дата
Msg-id CAFj8pRAhtXRAvX=Kt=XLoA_6n1SqATvAyfaLrE9fkvoYTSYPMw@mail.gmail.com
обсуждение исходный текст
Ответы Re: slow array(subselect)  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Список pgsql-hackers
Hi

Just curious

postgres=# explain analyze select array_upper(array_agg(i),1) from generate_series(1,100000) g(i);
                                                           QUERY PLAN                                                           
---------------------------------------------------------------------------------------------------------------------------------
 Aggregate  (cost=12.50..12.52 rows=1 width=4) (actual time=43.164..43.164 rows=1 loops=1)
   ->  Function Scan on generate_series g  (cost=0.00..10.00 rows=1000 width=4) (actual time=19.150..31.083 rows=100000 loops=1)
 Planning time: 0.100 ms
 Execution time: 44.392 ms
(4 rows)

postgres=# explain analyze select array_upper(array(select i from generate_series(1,1000000) g(i)),1);
                                                              QUERY PLAN                                                             
--------------------------------------------------------------------------------------------------------------------------------------
 Result  (cost=10.00..10.01 rows=1 width=4) (actual time=334.567..334.568 rows=1 loops=1)
   InitPlan 1 (returns $0)
     ->  Function Scan on generate_series g  (cost=0.00..10.00 rows=1000 width=4) (actual time=141.503..254.483 rows=1000000 loops=1)
 Planning time: 0.171 ms
 Execution time: 339.057 ms
(5 rows)

This code is about 8times slower

Regards

Pavel

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

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: Re: [HACKERS] user-defined numeric data types triggering ERROR:unsupported type
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Server won't start with fallback setting by initdb.