MySQL InnoDB query performance

荒凉一梦 提交于 2019-12-04 07:01:28
Jon Black

I hope you find the following links and previous answers of mine of interest.

I wish I could provide you with a specific answer to your problem but I dont have the time to get my head completely around your schema: naming conventions are so bad, lack of useful information, inconsistencies etc, etc...

However, you should find the solution to your problem below and it's nothing to do with switching to the less performant myisam engine !

A snippet from one of the answers below:

You should read the following and learn a little bit about the advantages of a well designed innodb table and how best to use clustered indexes - only available with innodb !

Clustered indexes:

http://dev.mysql.com/doc/refman/5.0/en/innodb-index-types.html

http://www.xaprb.com/blog/2006/07/04/how-to-exploit-mysql-index-optimizations/

Previous answers of mine:

60 million entries, select entries from a certain month. How to optimize database?

MySQL and NoSQL: Help me to choose the right one

How to avoid "Using temporary" in many-to-many queries?

Optimal MySQL settings for queries that deliver large amounts of data?

Hope this helps :)

(EDITED)

A (year, week) or (week, year) index in big_table would definitely help this query.

I see you already have the second one, (week, year). I would prefer the first one but for this query it would not make much difference, if any.


I would add:

  • a composite index (code_of_medium_table, year, week) in the big_table and

  • a composite index (code_of_small_table, indexed_field) in the medium_table.

Can you try it and post again the query plan?


Or (year, week, code_of_medium_table) and (indexed_field, code_of_small_table).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!