database - Suggest a Normalization in MySql -


i have brief experience mysql , don't have experience on normalization , denormalization techniques

we having analytics product. each of our customer give 1 javascript code, put in web sites. if user visit our customer site java script code hit our server store page visit on behalf of customer. each customer contains unique domain name means customer determined domain

we storing page visits in mysql table.

following table schema.

create table page_visits2 (   id bigint(20) unsigned not null auto_increment,   domain varchar(50) default null,   guid varbinary(16) default null,   sid varbinary(16) default null,   url varchar(2500) default null,   ip binary(16) default null,   is_new tinyint(1) default null,   ref varchar(2500) default null,   user_agent varchar(255) default null,   stats_time datetime default null,   country char(2) default null, (iso 3166-1 alpha-2)   region char(5) default null,  (iso-3166-2)   city varchar(50) default null,   city_lat_long varchar(50) default null,   email varchar(100) default null,   primary key (id),   key id (id) ) 

mysql server details

it google cloud mysql (version 5.6) , storage capacity 10tb.

as of having 350 million rows in our table , table size 300 gb.

so table size huge , index size big (approx 70 gb. ask regarding indexes in separate question).

for of our read/write queries depend on particular domain. don't query against multiple domains . where domain = 'domain_name' mandatory in queires. domian names doesn't change.

i want remove redundant data table , want reduce table size can put whole index in memory. @ same time want better performance of queries also. don't want loose query performance because of normalization. need normalization better performance of queries.

couple of approaches

  1. using domain_id instead of domain column in above table. create domains table separately (domain_name,domain_id)

  2. using address_id in place address related fields in above table. create addresses table , store address fields . (addresss_id,country,city,region,city_long_lat)

but don't know how implement above approaches. please tell above approaches correct or not , other better ideas ??

my main doubt if create seperate table domains example following query

select count(*) page_visits domain ='abc';  

i dont' know domain_id of domain 'abc' have call first domains table domain_id need call actual query.like address table need call address table address_id , actual query.

that means every read/write query i'm making 2 calls. doing mistakes here ???


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -