Archive of the day August 2, 2008

www.fab3.net - Urban Screen Milan 2008

Nessun commento » Miscellaneous , YouTube No Comments »

`Command` explain to optimize queries with MySQL

Nessun commento » MySQL , Open Source , Tips & Tricks No Comments »

When an application reaches a high level of complexity we risk losing sight of some of the details - apparently minor - which are often crucial for a smooth running and optimized the entire application.

Having to manage the database very articulated with MySQL , for example, incurs easily into small errors of evaluation on the actual consumption of resources that can generate a SQL statement. It may be useful in these cases use a simple tool that refreshments ideas about the structure of the table we're going to question: the `explain`.

Thanks to the `explain` you can analyze what indexes invokes a query, and optimize accordingly INSERT statements, especially when using multiple ones to store multiple rows with one SQL statement. The `explain` shows which indexes are used by each query, as well as other important information.

To make queries more efficient we need to ensure that all affected tables are read through the indexes, without undergoing a full shift (table scan). In this sense, the information obtained through `explain` can prove essential.