Re: Prepared statements and suboptimal plans
| От | Grzegorz Jaśkiewicz |
|---|---|
| Тема | Re: Prepared statements and suboptimal plans |
| Дата | |
| Msg-id | CAJY59_h40-A+=K4GV4SXcV1rk2acp2uc71nLaYpAycZ4YUCcqg@mail.gmail.com обсуждение исходный текст |
| Ответ на | Prepared statements and suboptimal plans (Royce Ausburn <esapersona@royce.id.au>) |
| Список | pgsql-performance |
one thing, in SUM() , you don't have to coalesce. Consider following example:
foo=# create table bar(id serial primary key, a float);
NOTICE: CREATE TABLE will create implicit sequence "bar_id_seq" for
serial column "bar.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"bar_pkey" for table "bar"
CREATE TABLE
Time: 666.094 ms
foo=# insert into bar(a) select random()*random()*random() from
generate_series(1, 1000) x;
INSERT 0 1000
Time: 496.451 ms
foo=# update bar set a = NULL where random() < 0.1;
UPDATE 97
Time: 150.599 ms
foo=# select sum(a) from bar;
sum
------------------
108.757220804033
(1 row)
Time: 277.227 ms
foo=# select sum(coalesce(a, 0.0)) from bar;
sum
------------------
108.757220804033
(1 row)
Time: 0.709 ms
But that obviously isn't going to improve it a lot.
В списке pgsql-performance по дате отправления: