php - How reduce mysql cpu usage In the below case -
i creating campaign tracking site. having 100 of tables. creating new table each month logging searches , clicks using create table if not exists
(the table consists of 23 fields , 9 indexes.). client complaining query telling hogging alot of cpu. it’s running on every request. creating table if it’s not exist ie, once per month. increase cpu usage? if yes ,is there way reduce cpu usage in case?
edit 1
create table if not exists click_log_201305 ( hit_id int(10) unsigned not null auto_increment, link_id int(11) not null default '0', word varchar(225) not null default '', ppc_engine varchar(40) not null default 'internal', ppc_commission varchar(10) default null, gross_price decimal(5,3) not null default '0.000', price decimal(5,3) not null default '0.000', hit_date int(11) not null default '0', hit_time int(11) not null default '0', affiliate varchar(50) not null default '', account varchar(50) not null default '', commission varchar(10) default null, paid_flag char(3) default null, roi_code int(11) not null default '0', roi_sale int(11) default null, debug_info varchar(100) default null, ip varchar(15) default null, referer varchar(200) default null, user_agent varchar(200) default null, subid varchar(50) default null, ad_id int(11) default null, group_id int(11) default null, country varchar(100) default null, primary key (hit_id), key jhcl_date(hit_date), key jhcl_src(hit_date,ppc_engine), key jhcl_id(hit_date,link_id), key jhcl_acct(hit_date,account), key jhcl_aff(hit_date,affiliate), key jhcl_word(hit_date,word), key jhcl_camp_id(link_id), key jhcl_group_id(group_id), key jhcl_ad_id(ad_id) )
place create table if not exists
cron job / scheduled task, , run 00.00 every day. query run once day. , when create new table add separate table (lets table_list), keep list of tables create.
then check table_list first check whether have created table current month. if cant find table in "table_list", create new one.
Comments
Post a Comment