This section lists a number of miscellaneous tips for improving query processing speed:
本节列出了一些提高查询处理速度的杂项技巧:
If your application makes several database requests to perform related updates, combining the statements into a stored routine can help performance.
如果应用程序发出多个数据库请求来执行相关更新,则将语句合并到存储的例程中可以帮助提高性能。
Similarly, if your application computes a single result based on several column values or large volumes of data, combining the computation into a loadable function can help performance.
类似地,如果应用程序基于多个列值或大量数据计算单个结果,则将计算合并到可加载函数中有助于提高性能。
The resulting fast database operations are then available to be reused by other queries, applications, and even code written in different programming languages.
由此产生的快速数据库操作可以被其他查询、应用程序甚至用不同编程语言编写的代码重用。
See Section 23.2, “Using Stored Routines” and Adding Functions to MySQL for more information
To fix any compression issues that occur with ARCHIVE
tables, use OPTIMIZE TABLE.
要修复ARCHIVE表出现的任何压缩问题,请使用OPTIMIZE TABLE。
See Section 15.5, “The ARCHIVE Storage Engine”.
If possible, classify reports as “live” or as “statistical”, where data needed for statistical reports is created only from summary tables that are generated periodically from the live data.
如果可能,将报告分类为“活动”或“统计”,其中统计报告所需的数据仅从从活动数据定期生成的汇总表中创建。
If you have data that does not conform well to a rows-and-columns table structure, you can pack and store data into a BLOB column.
如果数据不符合行和列表结构,可以将数据打包并存储到BLOB列中。
In this case, you must provide code in your application to pack and unpack information, but this might save I/O operations to read and write the sets of related values.
在这种情况下,您必须在应用程序中提供代码来打包和解包信息,但这可能会节省读和写相关值集的I/O操作。
With Web servers, store images and other binary assets as files, with the path name stored in the database rather than the file itself.
对于Web服务器,将图像和其他二进制资产存储为文件,路径名存储在数据库中,而不是文件本身。
Most Web servers are better at caching files than database contents, so using files is generally faster. (Although you must handle backups and storage issues yourself in this case.)
大多数Web服务器在缓存文件比缓存数据库内容方面做得更好,所以使用文件通常更快。(尽管在这种情况下,您必须自己处理备份和存储问题。)
If you need really high speed, look at the low-level MySQL interfaces.
如果你真的需要很高的速度,看看底层的MySQL接口。
For example, by accessing the MySQL InnoDB or MyISAM storage engine directly, you could get a substantial speed increase compared to using the SQL interface.
通过直接访问MySQL InnoDB或MyISAM存储引擎,与使用SQL接口相比,您可以获得显著的速度提高。
Similarly, for databases using the NDBCLUSTER storage engine, you may wish to investigate possible use of the NDB API (see MySQL NDB Cluster API Developer Guide).
类似地,对于使用NDBCLUSTER存储引擎的数据库,您可能希望调查NDB API的可能使用情况(参见MySQL NDB集群API开发指南)。
Replication can provide a performance benefit for some operations.
复制可以为某些操作提供性能优势。
You can distribute client retrievals among replicas to split up the load.
您可以在副本之间分配客户端检索,以分散负载。
To avoid slowing down the source while making backups, you can make backups using a replica.
为了避免在进行备份时降低源文件的速度,可以使用副本进行备份。