Optimizing MySQL Left join query between 3 tables to reduce execution time -


i have following query:

select region.id, region.world_id, min_x, min_y, min_z, max_x, max_y, max_z, version, mint_version  minecraft_worldguard.region  left join minecraft_worldguard.region_cuboid  on region.id = region_cuboid.region_id  , region.world_id = region_cuboid.world_id  left join minecraft_srvr.lot_version  on id=lot  region.world_id = 10  , region_cuboid.world_id=10; 

the mysql slow query log tells me takes more 5 seconds execute, returns 2300 rows examines 15'404'545 rows return it.

the 3 tables each have bout 6500 rows unique keys on id , lot fields keys on world_id fields. tried minimize amount of rows examined filtering both cuboid , world id , double on world_id, did not seem help.

any idea how can optimize query?

here sqlfiddle indexes of current status.

mysql can't use index in case because joined fields has different data types:

  `lot` varchar(20) collate utf8_unicode_ci not null   `id` varchar(128) collate utf8_bin not null 

if change types of fields general type (for example, region.id utf8_unicode_ci), mysql uses primary key (fiddle).

according docs:

comparison of dissimilar columns (comparing string column temporal or numeric column, example) may prevent use of indexes if values cannot compared directly without conversion.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -