Book Image

Mastering The Faster Web with PHP, MySQL, and JavaScript

By : Andrew Caya
Book Image

Mastering The Faster Web with PHP, MySQL, and JavaScript

By: Andrew Caya

Overview of this book

This book will get you started with the latest benchmarking, profiling and monitoring tools for PHP, MySQL and JavaScript using Docker-based technologies. From optimizing PHP 7 code to learning asynchronous programming, from implementing Modern SQL solutions to discovering Functional JavaScript techniques, this book covers all the latest developments in Faster Web technologies. You will not only learn to determine the best optimization strategies, but also how to implement them. Along the way, you will learn how to profile your PHP scripts with Blackfire.io, monitor your Web applications, measure database performance, optimize SQL queries, explore Functional JavaScript, boost Web server performance in general and optimize applications when there is nothing left to optimize by going beyond performance. After reading this book, you will know how to boost the performance of any Web application and make it part of what has come to be known as the Faster Web.
Table of Contents (19 chapters)
Title Page
Copyright and Credits
Dedication
Packt Upsell
Foreword
Contributors
Preface
Free Chapter
1
Faster Web – Getting Started
6
Querying a Modern SQL Database Efficiently
Index

SQL query performance


In order to better understand SQL query performance, we must first understand what indexes are and how they are built.

The structure of indexes

An index is an ordered list of table elements. These elements are first stored in a physically unordered doubly linked list. The list is doubly linked to the table through pointers to the table entries and to a second structure that stores the index values in a logical order, a balanced tree or b-tree. Thus, indexes have an algorithmic complexity that is logarithmic—O(log n)—for read operations on average, which means that the database engine should maintain speed even if there is a significant number of entries in the table. Indeed, an index lookup implies three steps:

  • The tree traversal
  • Searching the leaf node chain  
  • Fetching the data from the table

Thus, an index lookup is great when reading from the b-tree only, as you avoid the linear—O(n)—full table scan, for example. That being said though, you can never avoid the overhead...