sql - Improve query performance in MySQL -
i posting thread in order have advices regarding performance of sql query. have 2 tables, 1 called hgvs_snp
44657169 rows , on run
table has average of 2000 rows. when try update field comment of run table
takes lot's of time perform query. wondering if there method increase sql query.
structure of hgvs_snp table:
+-----------+-------------+------+-----+---------+-------+ | field | type | null | key | default | | +-----------+-------------+------+-----+---------+-------+ | snp_id | int(11) | yes | mul | null | | | hgvs_name | text | yes | | null | | | source | varchar(8) | no | | null | | | upd_time | varchar(32) | no | | null | | +-----------+-------------+------+-----+---------+-------+
my run table has following structure:
+----------------------+--------------+------+-----+---------+-------+ | field | type | null | key | default | | +----------------------+--------------+------+-----+---------+-------+ | id | varchar(7) | yes | | null | | | reference | varchar(7) | yes | mul | null | | | hgvsvar2 | varchar(120) | yes | mul | null | | | comment | varchar(120) | yes | | null | | | compute | varchar(20) | yes | | null | | +----------------------+--------------+------+-----+---------+-------+
here's query:
update run inner join snp_hgvs on run.hgvsvar2=snp_hgvs.hgvs_name set run.comment=concat('rs',snp_hgvs.snp_id) run.compute not 'tron'
i`m guessing since join text column varchar(120) column don`t need text column. make varchar can index it
alter table `hgvs_snp` modify hgvs_name varchar(120); alter table `hgvs_snp` add key idx_hgvs_name (hgvs_name);
this take while on large tables
now join should faster,also add index on compute column
alter table `run` add key idx_compute (compute);
and unnecessary,change
where run.compute != 'tron'
Comments
Post a Comment