· 6 years ago · Apr 18, 2019, 04:02 PM
1set max_parallel_workers_per_gather = 0;
2
3-- create table
4drop table if exists testreals;
5create table testReals(a real not null, b real not null);
6drop table if exists testDecimals;
7create table testDecimals(a decimal not null, b decimal not null);
8
9-- load data
10copy testReals from '/tmp/data.csv' delimiter ',' csv;
11copy testDecimals from '/tmp/data.csv' delimiter ',' csv;
12
13-- compare the decimal's trade-off cost as almost twice as real
14explain select sum(a+b) from testReals; -- show execute plan
15explain select sum(a+b) from testDecimals; -- show execute plan
16
17-- Execution Time: 152.728 ms
18explain analyze select sum(a+b) from testReals;
19
20-- Execution Time: 301.501 ms
21explain analyze select sum(a+b) from testDecimals;