By Justin Silverton
- use the explain command
Use multiple-row INSERT statements to store many rows with one SQL statement.
The explain command can tell you which indexes are used with the specified query and many other pieces of useful information that can help you choose a better index or query.
Example of usage: explain select * from table
explanation of row output:
- table—The name of the table.
- type—The join type, of which there are several.
- possible_keys—This column indicates which indexes MySQL could use to find the rows in this table. If the result is NULL, no indexes would help with this query. You should then take a look at your table structure and see whether there are any indexes that you could create that would increase the performance of this query.
- key—The key actually used in this query, or NULL if no index was used.
- key_len—The length of the key used, if any.
- ref—Any columns used with the key to retrieve a result.
- rows—The number of rows MySQL must examine to execute the query.
- extra—Additional information regarding how MySQL will execute the query. There are several options, such as Using index (an index was used) and Where (a WHERE clause was used).
- use less complex permissions
The more complex your permissions setup, the more overhead you have. Using simpler permissions when you issue GRANT statements enables MySQL to reduce permission-checking overhead when clients execute statements.
- specific mysql functions can be tested using the built-in “benchmark” command
If your problem is with a specific MySQL expression or function, you can perform a timing test by invoking the BENCHMARK() function using the mysql client program. Its syntax is BENCHMARK(loop_count,expression). The return value is always zero, but mysql prints a line displaying approximately how long the statement took to execute
- optimize where clauses
- Remove unnecessary parentheses
- COUNT(*) on a single table without a WHERE is retrieved directly from the table information for MyISAM and MEMORY tables. This is also done for any NOT NULL expression when used with only one table.
- If you use the SQL_SMALL_RESULT option, MySQL uses an in-memory temporary table
- Run optimize table
This command defragments a table after you have deleted a lot of rows from it.
- avoid variable-length column types when necessary
For MyISAM tables that change frequently, you should try to avoid all variable-length columns (VARCHAR, BLOB, and TEXT). The table uses dynamic row format if it includes even a single variable-length column.
- insert delayed
Use insert delayed when you do not need to know when your data is written. This reduces the overall insertion impact because many rows can be written with a single disk write.
- use statement priorities
- Use INSERT LOW_PRIORITY when you want to give SELECT statements higher priority than your inserts.
- Use SELECT HIGH_PRIORITY to get retrievals that jump the queue. That is, the SELECT is executed even if there is another client waiting.
- use multiple-row inserts
Use multiple-row INSERT statements to store many rows with one SQL statement.
- synchronize data-types
Columns with identical information in different tables should be declared to have identical data types so that joins based on the corresponding columns will be faster.
分享到:
相关推荐
此外,如果可能,将循环移入函数调用内(例如将for循环直接写入函数内),并且对于长的if-else链,应该尽可能转换为switch语句,这是因为编译器有时会将switch语句优化为使用单一跳转的表查找。如果switch语句不适用...
#### 10. 我们试图解决的问题是什么? - **目标**:如何从SQL Server部署中获得最大价值? - **核心问题**:我们是否正以最佳效率运行?应用程序能否顺利扩展? - **可扩展性定义**:一个可扩展的系统是指随着...
文件标题为"Alberto Ferrari_Optimizing DAX Queries",由此可以推断出这是一篇专注于数据建模语言DAX(Data Analysis Expressions)查询优化的参考资料。文档的描述部分提到了BI(Business Intelligence)软件、...
Optimizing Java Practical Techniques for Improved 完整版,不是early release
This guide explores how to tune and optimize the MySQL Cluster database to handle diverse workload requirements. It discusses data access patterns and how to build distribution awareness into ...
High Performance Spark Best Practices for Scaling and Optimizing Apache Spark 英文azw3 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
High Performance Spark Best Practices for Scaling and Optimizing Apache Spark 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
Topics such as migrating to MySQL 8, MySQL benchmarking, achieving high performance by implementing the indexing techniques, and optimizing your queries are covered in this book. You will also learn ...
High Performance Spark: Best Practices for Scaling and Optimizing Apache Spark by Holden Karau English | 25 May 2017 | ASIN: B0725YT69J | 358 Pages | AZW3 | 3.09 MB Apache Spark is amazing when ...
MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下产品。MySQL 是最流行的关系型数据库管理系统之一,在 WEB 应用方面,MySQL是最好的 RDBMS (Relational Database Management ...
#### 10. 依赖性测试 依赖性测试是确保编译器正确性的重要环节。这部分内容深入探讨了如何进行有效的依赖性测试,包括: - **背景与术语**:定义了一些关键概念,如索引、非线性等。 - **依赖性测试概述**:介绍了...
MySQL 8 Administrator's Guide pdf Step by step guide to monitor, manage, and secure your database ...Optimizing MySQL 8 Extending MySQL 8 MySQL 8 Best Practices & Benchmarking Troubleshooting MySQL 8
Mind+Machine A Decision Model for Optimizing and Implementing Analytics 英文无水印原版pdf pdf所有页面使用FoxitReader、PDF-XChangeViewer、SumatraPDF和Firefox测试都可以打开 本资源转载自网络,如有...
Pub Date: 2018 Learn how Java principles and technology make the best use of modern hardware and operating systems Explore several performance tests and common anti-patterns that can vex your team ...
Optimizing Java_Practical Techniques for Improving JVM Application Performance-O’Reilly(2018) How do you define performance? Most developers, when asked about the performance of their application, ...
Optimizing Java Practical Techniques for Improved Performance Tuning 英文mobi 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
Optimizing Java Practical Techniques for Improved Performance Tuning 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
"High Performance Spark Best Practices for Scaling and Optimizing Apache Spark" 这一主题深入探讨了如何最大化利用Spark的性能,以及如何进行有效扩展和优化。以下是一些关键的知识点: 1. **资源管理与调度**...