Home >Backend Development >PHP Tutorial >Problems with select count(*) query optimization and index building when there is multiple data

Problems with select count(*) query optimization and index building when there is multiple data

WBOY
WBOYOriginal
2016-08-18 09:15:521229browse

InnoDB table type, select count(*) where condition is followed by 12 query values, and it takes about 5 seconds to query 500,000 pieces of data without indexing. I would like to ask if building an index column is the best solution for this situation. By the way, is the consumption of an index column and an index equal? ​​For example, it affects the efficiency of additions, deletions, and modifications, space size, etc. Thank you

Reply content:

InnoDB table type, select count(*) where condition is followed by 12 query values, and it takes about 5 seconds to query 500,000 pieces of data without indexing. I would like to ask if building an index column is the best solution for this situation. By the way, is the consumption of an index column and an index equal? ​​For example, it affects the efficiency of additions, deletions, and modifications, space size, etc. Thank you

500,000 in 5 seconds is too slow. . You need to build a joint index based on your query conditions

Please post the query statement as well

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn