优化my.cnf参数以提高mysql查询执行时间速度

时间:2015-06-02 07:10:14

标签: mysql configuration database-performance

我有数据库,有一万亿条记录插入到20个Myisam mysql表中,我的程序每次执行800个选择mysql查询,其中包含多个连接和索引,所以我如何优化my.cnf参数来提高mysql查询执行时间速度因为每个mysql查询的发送数据时间都很长。

mysql查询是 选择nl.ndc,formulary_status FROM bh.webdav_formulary_detail wfd INNER JOIN bh.payer_map pm ON wfd.payer_map_id = pm.payer_map_id INNER JOIN bh.ndc_lookup nl ON wfd.product_id = nl.uid WHERE pm.payer_id ='P00000000001001'和pm。 formulary_id ='01244'和nl.ndc in('16590061572','35356078830','35356078860','35356078890','49999085690','54868381500','54868381501','54868381503','54868381504','54868381505' ,'59011044010','59011044020','63629377401','63629377402','63629377403');

SHOW CREATE TABLE webdav_formulary_detail;

|表|创建表| + ------------------------- + ----------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- --------------------- + | webdav_formulary_detail | CREATE TABLE webdav_formulary_detail(   product_id mediumint(8)unsigned NOT NULL,   formulary_status char(2)NOT NULL,   file_iid smallint(5)unsigned NOT NULL DEFAULT'0',   payer_map_id smallint(5)unsigned NOT NULL,   KEY payer_map_idpayer_map_id),   KEY product_idproduct_id) )ENGINE = MyISAM DEFAULT CHARSET = latin1 |

SHOW CREATE TABLE ndc_lookup; + ------------ + ------------------------------------ -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ------------------------- + |表|创建表| + ------------ + ------------------------------------ -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ------------------------- + | ndc_lookup | CREATE TABLE ndc_lookup(   uid mediumint(8)unsigned NOT NULL,   ndc char(11)NOT NULL DEFAULT'0',   PRIMARY KEY(uid),   KEY uiduid),   KEY ndcndc) )ENGINE = MyISAM DEFAULT CHARSET = latin1 |

SHOW CREATE TABLE payer_map; + ----------- + ------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------- + |表|创建表| + ----------- + ------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------------- + | payer_map | CREATE TABLE payer_map(   payer_map_id smallint(5)unsigned NOT NULL,   payer_id varchar(80)DEFAULT NULL,   formulary_id varchar(50)DEFAULT NULL,   alternate_id varchar(50)DEFAULT NULL,   PRIMARY KEY(payer_map_id),   KEY payer_map_idpayer_map_id),   KEY payer_idpayer_id),   KEY formulary_idformulary_id),   KEY alternate_idalternate_id) )ENGINE = MyISAM DEFAULT CHARSET = latin1 |

1 个答案:

答案 0 :(得分:0)

我使用this取得了一些成功,这是一个perl脚本,用于分析您的设置并提出一些建议。