I want to create new table from existing table without ‘hour’ separation so I would have less rows per date.
is there a way to do it without involving a middle man script and just use SQL?
my server is VPS with 4GB ram, 2 cores, data is 45+Million rows, running MariaDB 5.5.
here is my current table scheme:
TableBig:
id bigint(20) unsigned Auto Increment
folder_id int(9) unsigned
user_id int(9) unsigned
tag_id int(11) unsigned
tag_type enum('m','t')
date date
year int(4) unsigned
month tinyint(2) unsigned
day tinyint(2) unsigned
hour tinyint(2) unsigned
country varchar(2)
domain_id int(10) unsigned
url_id bigint(20) unsigned
unique_imprs int(11) unsigned
unique_actions int(11) unsigned
unique_clicks int(11) unsigned
gross_imprs int(11) unsigned
gross_clicks int(11) unsigned
gross_actions int(11) unsigned
transfer_bytes bigint(20) unsigned
here is my indexes:
Indexes
PRIMARY id
INDEX date, tag_id
INDEX date, folder_id
INDEX date, user_id
my new table should look like this (Notice: no hour column):
TableSmall:
id bigint(20) unsigned Auto Increment
folder_id int(9) unsigned
user_id int(9) unsigned
tag_id int(11) unsigned
tag_type enum('m','t')
date date
year int(4) unsigned
month tinyint(2) unsigned
day tinyint(2) unsigned
country varchar(2)
domain_id int(10) unsigned
url_id bigint(20) unsigned
unique_imprs int(11) unsigned
unique_actions int(11) unsigned
unique_clicks int(11) unsigned
gross_imprs int(11) unsigned
gross_clicks int(11) unsigned
gross_actions int(11) unsigned
transfer_bytes bigint(20) unsigned