I try to experiment with different types of models to find the best balance between performance and maintenance. So I started to play around with jsonb. I try to simulate storing measurement from sensors.
I have tested two schemas:
CREATE TABLE yuga_json_1
(
country INT NOT NULL,
province INT NOT NULL,
id BIGINT NOT NULL,
yearmonth INT NOT NULL,
measurement jsonb NOT NULL,
creation_date timestamp,
CONSTRAINT pk PRIMARY KEY (country ASC, province ASC, id ASC, yearmonth ASC)
)
where measurement structure looks as follows:
{
"<day_of_month": [
{
"p": 12,
"q": 2,
"value": 924.08
},
collection of various measurements...
For this structure, I have stored around 291463 records with 108911008 measurements in total.
And then I have tried with more records but less nested jsonb structure.
CREATE TABLE yuga_json_2
(
country INT NOT NULL,
province INT NOT NULL,
id BIGINT NOT NULL,
yearmonthday INT NOT NULL,
measurement jsonb NOT NULL,
creation_date timestamp,
CONSTRAINT pk PRIMARY KEY (country ASC, province ASC, id ASC, yearmonthday ASC)
)
where measurement structure looks as follows:
[
{
"p": 12,
"q": 2,
"value": 924.08
},
collection of various measurements...
For this structure, I have stored around 8452427 records with the same number of measurements in total.
What is the source of such a differences ? Do I measure the space needed for storing those data correctly ?