From: | Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com> |
---|---|
To: | Royce Ausburn <esapersona(at)royce(dot)id(dot)au> |
Cc: | pgsql-performance <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Prepared statements and suboptimal plans |
Date: | 2011-09-21 14:49:54 |
Message-ID: | CAJY59_h40-A+=K4GV4SXcV1rk2acp2uc71nLaYpAycZ4YUCcqg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Klemme | 2011-09-21 14:51:26 | Re: Slow query with self-join, group by, 100m rows |
Previous Message | Claudio Freire | 2011-09-21 14:19:27 | Re: [PERFORM] parámetros de postgres y linux en maquinas virtuales |