search
HomeDatabaseMysql Tutorial读《Effectove MySQL之SQL语句最优化》的有感!

MySQL 数据库由于性能高,成本低,可靠性好等优点,已经成为最流行的开源关系型数据库产品,广泛地被使用在互联网上的中小型网站中。并且随着MySQL的不断成熟,以及一些企业特性的加入,它也逐渐被用于更大规模的网站和应用系统中,如我们知道的维基百科,谷

MySQL 数据库由于性能高,成本低,可靠性好等优点,已经成为最流行的开源关系型数据库产品,广泛地被使用在互联网上的中小型网站中。并且随着MySQL的不断成熟,以及一些企业特性的加入,它也逐渐被用于更大规模的网站和应用系统中,如我们知道的维基百科,谷歌和facebook等。目前互联网上流行的网站架构方式LAMP,WNMP和LNMP,其中的“M”都是MySQL,这些都是免费或开放源代码软件,使用这种方式可以以很低的成本构建网站系统和其它应用。因此,MySQL越来越受到企业和个人开发者的厚爱。

 

MySQL是一个非常容易上手的数据库产品,很多人只要很短的时间就可以使用它。但是,作为一个有经验的的数据库应用程序的开发者写出来的sql查询语句和新手写出的sql语句在执行性能方面有巨大的差别,其根本的原因在于有经验的数据库应用开发者善于运用mysql的索引以及各种性能分析调优工具优化自己的查询。

 

但是,估计现在很多做开发的,对数据库优化都只是一个不是很清晰的概念或者一个全面的理解。我也是其中一个,虽然自己搞MySQL很长时间了。但大多数的情况下只是简单的使用sql语句,骨子里一直认为数据库应该是有专门的人士来搞,而这个人不应该是我这样的开发者。但是从实际上来看,这个角色经常是由开发人员来担任的。也就是说,作为一名日常“开发人员”,除了完成自己的本职工作外,最常重复的工作就是在生产环境中检查和优化运行的SQL语句。当MySQL软件安装、配置以及正常运行之后,监控数据库的性能问题就成为一项经常重复的工作。了解如何正确地截取有问题的SQL语句以及检查并做适当的调整,这已经成为一个专业技术人员的必备技能。

 

曾经一直以为使用一个alter语句在什么时候都可以的,可没想过要考虑什么因素,可刚看到《Effectove MySQL之SQL语句最优化》的第一章第二节就有这么一句话“在此期间,由于aletr语句是阻塞操作,因此所有为表添加和修改数据的额外请求都被阻塞了”。在这之前,一直都认为无论何时给一个表增加或者修改字段都可以的,根本没想过会影响其他的因素。《Effectove MySQL之SQL语句最优化》的第一章就讲了如何寻找缓慢的SQL语句,同时也介绍了几种用于优化语句的分析工具,包括EXPLAIN和SHOW CREATE TABLE。同时了解了应该重点关注能够识别性能问题的那些属性。同时知道优化SQL语句绝不仅仅是添加索引。这个虽然很早就知道,不过刚接触的SQL的都不太清楚。

 

下面我们看一下该书的目录图:

读《Effectove MySQL之SQL语句最优化》的有感!

 

全书一共分为8章,每一章还有小结,全书很值得一读,学完了对mysql优化有一个进步的提升。本书的作者是Ronald Bradford,它写过一本《PHP+MySQL专家编程》,我没有看过中译本,因为它刚刚被引进,看过英文的电子版,写的还是不错的,因此,本书的内容还是很值得一看的。

该书是按照概念,实例,总结的模式来写的,比较符合学习知识的认知过程。该书不是很厚,只有短短的200页,这类书可以普遍归结到我们目前有的比如21天学通Java,什么24小时学通MySQL之类,但这本书比那些书要好很多,至少不是胡编乱造,抄写help吧,至少mysql的帮助也很少提供有关优化的方法,最多会给出一些概念罢了!

 

推荐指数:四星级

适合人群:有一定sql基础,想继续学习提供的人群

 

前面说了那么多,还是说说读完后的感想:老外写的书大都是比较贴近实际,比较务实的。 重点还是介绍了MySQL在调优过程中,常见的方法,以及适用的场景。
 案例占据了书的一半版面,读者跟随书的介绍做一遍,一定会有不同程度的收获,属于开卷有益类的书籍

其实最有效的sql优化方法应该是:大处着眼,小处着手,通盘考虑,先看后动
 具体的技术手段很多,索引,分区,配置等等,但都需要在深入理解问题以后,才能更好的解决问题

但本书还是存在的一些小毛病,就是在进行技术细节概念讲述的时候,并不直接给出概念的定义,而是跳跃式的讲解,很容易打断人的思路,我看的时候会时不时思想就开了小差,也许不太喜欢这类讲法吧!

还有就是没有指出案例是在什么环境下运行,windows还是linux还是别的什么环境下,因为,我在windows环境下运行了某些实例,发现居然有些不能运行,真是比较晕。

 

写的比较乱,不妥之处还忘大家海涵!

 

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
Reduce the use of MySQL memory in DockerReduce the use of MySQL memory in DockerMar 04, 2025 pm 03:52 PM

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

How to solve the problem of mysql cannot open shared libraryHow to solve the problem of mysql cannot open shared libraryMar 04, 2025 pm 04:01 PM

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

How do you alter a table in MySQL using the ALTER TABLE statement?How do you alter a table in MySQL using the ALTER TABLE statement?Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

Run MySQl in Linux (with/without podman container with phpmyadmin)Run MySQl in Linux (with/without podman container with phpmyadmin)Mar 04, 2025 pm 03:54 PM

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

What is SQLite? Comprehensive overviewWhat is SQLite? Comprehensive overviewMar 04, 2025 pm 03:55 PM

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

How do I configure SSL/TLS encryption for MySQL connections?How do I configure SSL/TLS encryption for MySQL connections?Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

Running multiple MySQL versions on MacOS: A step-by-step guideRunning multiple MySQL versions on MacOS: A step-by-step guideMar 04, 2025 pm 03:49 PM

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)?What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)?Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

See all articles

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),