Home Database Mysql Tutorial Mysql入门系列:优化MYSQL_MySQL

Mysql入门系列:优化MYSQL_MySQL

Jun 01, 2016 pm 01:56 PM
optimization user

  4.6 管理员的优化

  前面各段介绍了普通的MySQL用户利用表创建和索引操作,以及利用查询的编写能够进行的优化。不过,还有一些只能由MySQL管理员和系统管理员来完成的优化,这些管理员在MySQL服务器或运行MySQL的机器上具有控制权。有的服务器参数直接适用于查询处理,可将它们打开。而有的硬件配置问题直接影响查询处理速度,应该对它们进行调整。

  4.6.1服务器参数

  服务器有几个能够改变从而影响其操作的参数(或称变量)。有关服务器参数优化的综合介绍请参见第11章,但其中几个参数主要与查询有关,有必要在此提一下:

  ■ delayed _ queue _ size

  此参数在执行其他INSERT DELAYED 语句的客户机阻塞以前,确定来自INSERT DELAYED 语句的放入队列的行的数目。增加这个参数的值使服务器能从这种请求中接收更多的行,因而客户机可以继续执行而不阻塞。

  ■ key _ buffer _ size

  此参数为用来存放索引块的缓冲区尺寸。如果内存多,增加这个值能节省索引创建和修改的时间。较大的值使MySQL能在内存中存储更多的索引块,这样增加了在内存中找到键值而不用读磁盘块的可能性。在MySQL3.23 版及以后的版本中,如果增加了键缓冲区的尺寸,可能还希望用- - init -file 选项启动服务器。这样能够指定一个服务器启动时执行的SQL 语句文件。如果有想要存放在内存中的只读表,可将它们拷贝到索引查找非常快的HEAP 表。

  4.6.2 硬件问题

  可利用硬件更有效地改善服务器的性能:

  ■ 在机器中安装更多的内存。这样能够增加服务器的高速缓存和缓冲区的尺寸,使服务器更经常地使用存放在内存中的信息,降低从磁盘取信息的要求。

  ■ 如果有足够的RAM 使所有交换在内存文件系统中完成,那么应该重新配置系统,去掉所有磁盘交换设置。否则,即使有足以满足交换的R A M,某些系统仍然要与磁盘进行交换。

  ■ 增加更快的磁盘以减少I/O 等待时间。寻道时间是这里决定性能的主要因素。逐字地移动磁头是很慢的,一旦磁头定位,从磁道读块则较快。

  ■ 在不同的物理设备上设法重新分配磁盘活动。如果可能,应将您的两个最繁忙的数据库存放在不同的物理设备上。请注意,使用同一物理设备上的不同分区是不够的。这样没有帮助,因为它们仍将争用相同的物理资源(磁盘头)。移动数据库的过程在第10

  章中介绍。

  在将数据重新放到不同设备之前,应该保证了解该系统的装载特性。如果在特定的物理设备上已经有了某些特定的主要活动,将数据库放到该处实际上可能会使性能更坏。例如,不要把数据库移到处理大量Web 通信的Web 服务器设备上。

  ■ 在设置MySQL时,应该配置其使用静态库而不是共享库。使用共享库的动态二进制系统可节省磁盘空间,但静态二进制系统更快(然而,如果希望装入用户自定义的函数,则不能使用静态二进制系统,因为UDF 机制依赖于动态连接)。

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use Xiaohongshu account to find users? Can I find my mobile phone number? How to use Xiaohongshu account to find users? Can I find my mobile phone number? Mar 22, 2024 am 08:40 AM

With the rapid development of social media, Xiaohongshu has become one of the most popular social platforms. Users can create a Xiaohongshu account to show their personal identity and communicate and interact with other users. If you need to find a user’s Xiaohongshu number, you can follow these simple steps. 1. How to use Xiaohongshu account to find users? 1. Open the Xiaohongshu APP, click the "Discover" button in the lower right corner, and then select the "Notes" option. 2. In the note list, find the note posted by the user you want to find. Click to enter the note details page. 3. On the note details page, click the "Follow" button below the user's avatar to enter the user's personal homepage. 4. In the upper right corner of the user's personal homepage, click the three-dot button and select "Personal Information"

Log in to Ubuntu as superuser Log in to Ubuntu as superuser Mar 20, 2024 am 10:55 AM

In Ubuntu systems, the root user is usually disabled. To activate the root user, you can use the passwd command to set a password and then use the su- command to log in as root. The root user is a user with unrestricted system administrative rights. He has permissions to access and modify files, user management, software installation and removal, and system configuration changes. There are obvious differences between the root user and ordinary users. The root user has the highest authority and broader control rights in the system. The root user can execute important system commands and edit system files, which ordinary users cannot do. In this guide, I'll explore the Ubuntu root user, how to log in as root, and how it differs from a normal user. Notice

Analysis of user password storage mechanism in Linux system Analysis of user password storage mechanism in Linux system Mar 20, 2024 pm 04:27 PM

Analysis of user password storage mechanism in Linux system In Linux system, the storage of user password is one of the very important security mechanisms. This article will analyze the storage mechanism of user passwords in Linux systems, including the encrypted storage of passwords, the password verification process, and how to securely manage user passwords. At the same time, specific code examples will be used to demonstrate the actual operation process of password storage. 1. Encrypted storage of passwords In Linux systems, user passwords are not stored in the system in plain text, but are encrypted and stored. L

In-depth interpretation: Why is Laravel as slow as a snail? In-depth interpretation: Why is Laravel as slow as a snail? Mar 07, 2024 am 09:54 AM

Laravel is a popular PHP development framework, but it is sometimes criticized for being as slow as a snail. What exactly causes Laravel's unsatisfactory speed? This article will provide an in-depth explanation of the reasons why Laravel is as slow as a snail from multiple aspects, and combine it with specific code examples to help readers gain a deeper understanding of this problem. 1. ORM query performance issues In Laravel, ORM (Object Relational Mapping) is a very powerful feature that allows

Decoding Laravel performance bottlenecks: Optimization techniques fully revealed! Decoding Laravel performance bottlenecks: Optimization techniques fully revealed! Mar 06, 2024 pm 02:33 PM

Decoding Laravel performance bottlenecks: Optimization techniques fully revealed! Laravel, as a popular PHP framework, provides developers with rich functions and a convenient development experience. However, as the size of the project increases and the number of visits increases, we may face the challenge of performance bottlenecks. This article will delve into Laravel performance optimization techniques to help developers discover and solve potential performance problems. 1. Database query optimization using Eloquent delayed loading When using Eloquent to query the database, avoid

C++ program optimization: time complexity reduction techniques C++ program optimization: time complexity reduction techniques Jun 01, 2024 am 11:19 AM

Time complexity measures the execution time of an algorithm relative to the size of the input. Tips for reducing the time complexity of C++ programs include: choosing appropriate containers (such as vector, list) to optimize data storage and management. Utilize efficient algorithms such as quick sort to reduce computation time. Eliminate multiple operations to reduce double counting. Use conditional branches to avoid unnecessary calculations. Optimize linear search by using faster algorithms such as binary search.

Discussion on Golang's gc optimization strategy Discussion on Golang's gc optimization strategy Mar 06, 2024 pm 02:39 PM

Golang's garbage collection (GC) has always been a hot topic among developers. As a fast programming language, Golang's built-in garbage collector can manage memory very well, but as the size of the program increases, some performance problems sometimes occur. This article will explore Golang’s GC optimization strategies and provide some specific code examples. Garbage collection in Golang Golang's garbage collector is based on concurrent mark-sweep (concurrentmark-s

Laravel performance bottleneck revealed: optimization solution revealed! Laravel performance bottleneck revealed: optimization solution revealed! Mar 07, 2024 pm 01:30 PM

Laravel performance bottleneck revealed: optimization solution revealed! With the development of Internet technology, the performance optimization of websites and applications has become increasingly important. As a popular PHP framework, Laravel may face performance bottlenecks during the development process. This article will explore the performance problems that Laravel applications may encounter, and provide some optimization solutions and specific code examples so that developers can better solve these problems. 1. Database query optimization Database query is one of the common performance bottlenecks in Web applications. exist

See all articles