query optimization - Optimize two simple MySQL queries - column indexes -


i novice in mysql query optimization , need advice on how optimize database 2 queries - indexes should set , where. below database structure , queries.

create table `data_node` (   `id` bigint(20) unsigned not null auto_increment,   `type` enum('node','place') default null,   `name` varchar(255) default '',   `source_id` bigint(20) unsigned default null,   `data_id` bigint(20) unsigned not null,   `data_lat` decimal(8,6) not null,   `data_lon` decimal(9,6) not null,   primary key (`id`) ) engine=myisam default charset=utf8;  create table `data_node_tag` (   `id` bigint(20) unsigned not null auto_increment,   `node_id` bigint(20) unsigned not null,   `data_key` varchar(255) not null default '',   `data_value` varchar(255) not null default '',   primary key (`id`) ) engine=myisam default charset=utf8; 

first query:

select * data_node n left join data_node_tag nt on nt.node_id = n.id n.type = "place"   , nt.data_value "%place%" group n.data_id limit 100 

second query:

select * data_node n left join data_node_tag nt on nt.node_id = n.id n.source_id = 123   , n.type = "node"   , nt.data_value = "cafe"   , (n.data_lat between 1.000000 , 2.000000)   , (n.data_lon between 3.000000 , 4.000000) group n.data_id limit 1000 

i grateful help.

for first query, want index on data_node(type, id, data_id) , data_node_tag(node_id, data_value).

for second query, want index on data_node(source_id, type, data_lat, data_long, id) , data_node_tag(id, data_value) (this same first query).


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -