On comparing Mysql and Postgres table sizes we found that:
Postgre Table size (4758390 rows) (vanilla postgres): 1402MB
Data Length = 1063MB Index Length = 339MB
Mysql Table Size (4758390 rows) (with Inno DB): 1056MB
Data Length = 845MB Index Length = 211MB
The tables have the following schema:-
The schema:-
MySQL
int(11)
varchar(15)
datetime
float
float
float
float
float
double
double
double
float
longtext
double
double
int(11)
double
float
int(11)
int(11)
float
int(11)
int(11)
int(11)
int(11)
varchar(50)
int(11)
int(11)
int(11)
Postgres
serial
varchar
timestamp
double precision
double precision
double precision
double precision
double precision
numeric
numeric
numeric
double precision
varchar
numeric
numeric
double precision
numeric
double precision
integer
integer
double precision
integer
integer
integer
integer
varchar
integer
integer
integer
The query used to calculate the sizes for the tables are:-
MySQL
SELECT table_name AS `Table`,data_length, index_length,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
WHERE table_schema = "DB_NAME
AND table_name = "TABLE_NAME";
Postgres
SELECT pg_size_pretty(pg_total_relation_size('TABLE_NAME'));
Edit:-
Indexes in MySQL: Size
(varchar(15),datetime) -> 133 MB
(datetime) -> 78 MB
Indexes in Postgres: Size
(varchar,timestamp) -> 339 MB
I am new to databases and wondering how is this possible.