Showing entries 14973 to 14982 of 44965
« 10 Newer Entries | 10 Older Entries »
When is a Subquery Executed?

In an earlier blog post, I managed to confuse myself as to when a subquery was executed. It is not very clear from the output of EXPLAIN where the execution of a subquery takes place. Let's take a look at the following example query (Query 17 in the DBT-3 benchmark):

select sum(l_extendedprice) / 7.0 as avg_yearly
from lineitem, part
where p_partkey = l_partkey
and p_brand = 'Brand#33' and p_container = 'LG CAN'
and l_quantity < (
select 0.2 * avg(l_quantity)
from lineitem
where l_partkey = p_partkey
);

If you run EXPLAIN on this query, you will see the following execution plan:

+----+--------------------+----------+------+---------------------------------+---------------------+---------+---------------------+---------+-------------+
| id | select_type …
[Read more]
Fastest way to estimate rows in a table

A friend wrote to me recently with a question. He was working on a method to ship application metrics to statsd on a 1 minute interval. He had three examples of how to estimate the number of rows in a table and he wanted to know the difference between them.

Data length/average row length

The example given:

mysql> select DATA_LENGTH/AVG_ROW_LENGTH from INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'line_items';
+----------------------------+
| DATA_LENGTH/AVG_ROW_LENGTH |
+----------------------------+
|              10497541.7528 |
+----------------------------+
1 row in set (0.03 sec)

I have actually never thought of using this method! I don’t think it’s accurate though, since data length has deleted space + additional preallocated or overhead space. For example a page file is only …

[Read more]
OPTIMIZE/CHECK/REPAIR/ANALYZE TABLE InnoDB Edition

I find a good interview question for a MySQL DBA position is to ask what the following commands actually do in InnoDB, which has been the default storage engine since MySQL 5.5. From my perspective there is a lot of miss-understanding what still applies.

ANALYZE TABLE

From the MySQL manual:

ANALYZE TABLE analyzes and stores the key distribution for a table. During the analysis, the table is locked with a read lock for InnoDB and MyISAM.

What this means is, as part of query optimization MySQL will often have to decide which is the best index if there are multiple candidates, which indexes should be avoided, and what order should tables be joined in. Indexes need to eliminate work - so if for example you were trying to index a column called “Country” in a table full of all people in the USA, then it would be faster to …

[Read more]
Database Master-Slave Replication in the Cloud

This is a guest post from Jelastic.

Many developers use master-slave replication to solve a number of different problems, including problems with performance, supporting the backup of different databases, and as a part of a larger solution to alleviate system failures. Traditionally, master-slave replication is done with real servers, but it can also be done with cloud database servers. This guest post from Jelastic (originally published here) describes how to set up MariaDB master-slave replication using their Jelastic PaaS (Platform as a Service).

Replication Overview

Master-slave replication enables data from one database server (the master) to be replicated to one or more other database servers (the …

[Read more]
Database Master-Slave Replication in the Cloud

Wed, 2013-05-01 18:54 About the Author Daniel Bartholomew

Daniel is a System Administrator, Documenter, and author of the recently released Getting Started with MariaDB

Many developers use master-slave replication to solve a number of different problems, including problems with performance, supporting the backup of different databases, and as a part of a larger solution to alleviate system failures. Traditionally, master-slave replication is done with real servers, but it can also be done with cloud database servers. This guest post from Jelastic (originally published here) describes how to set up MariaDB master-slave replication using their Jelastic PaaS (Platform as a Service).

Replication Overview

Master-slave replication enables data from one …

[Read more]
Slides from Percona Live talks: optimizer tutorial and Cassandra Storage Engine

I’ve put online the slides for the two talks that I сo-presented at the Percona Live conference:

[Read more]
Book Review – MySQL Workbench: Data Modeling & Development


MySQL Workbench: Data Modeling & Development
Michael McLaughlin
Oracle Press
ISBN 978-0-07-178188-5

MySQL Workbench is one of those tools that quickly becomes invaluable. It is a SQL query tool, a data modeler, and an admin tool all in one. As such a complicated tool, there is a bit of a learning curve before one can move beyond the basic functionality. Now there is a book that not only is a guided tour of MySQL Workbench but it contains little snippets full of DBA and system admin tricks that make this a must have for anyone using Workbench.

The book is divided into six sections that starts with configuration. This part of the book assumes now previous database or MySQL background as it gently guides you through the installation of the key components on mac OS X, Windows, and Linux. …

[Read more]
Got a packet bigger than ‘slave_max_allowed_packet’ bytes and binlog_format = STATEMENT | MIXED

Send to Kindle

Got a packet bigger than ‘slave_max_allowed_packet’ bytes and binlog_format=STATEMENT|MIXED

Since version 5.1.64 MySQL introduces a new variable named slave_max_allowed_packet, which was introduced to allow large updates using row-based replication do not cause replication to fail when exceeded max_allowed_packet.

The problem is if you have you replication using binlog_format=STATEMENT or binlog_format=MIXED it ignores this option and use as limit for queries what is on max_allowed_packet variable but still reporting on slave_max_allowed_packet causing the IO_THREAD to report the wrong message.

Solution:
Run the …

[Read more]
5 years of MySQL

5 years of MySQL

People often write a blog post when they reach some nice anniversary since they joined MySQL community. Well, for those old enough it usually means when they joined MySQL AB as employee. For me this was January 2008. Because I didn't remember the month correctly, I haven't blogged anything then, but decided to save it for a better opportunity - now.

TL;DR Starting this week I will be working for 10gen, selling MongoDB to the Nordics. This blog post is really long - even then it doesn't contain the most interesting stories, I'm not sure if they can ever be published. Sorry for the length, but remember you don't need to read all at once. This is my last MySQL post so save some of it for cold winter days!

2008 - Sun acquisition

read more

Follow these basics when migrating to Percona XtraDB Cluster for MySQL

Galera/Percona XtraDB Cluster (PXC) for MySQL is a hot thing right now and some users jump right in without enough testing. Consequently, they’re more likely to either suffer failure or issues that prevent them from moving forward. If you are thinking of migrating your workload to Percona XtraDB Cluster, make sure to go through these basics.

log_slave_updates is REQUIRED

You need to have log_slave_updates enabled on the cluster node acting as async slave for replicated events from the async master to be applied to the other nodes, that is if you have more than one PXC node. This is because before Galera can create writesets for the replicated events, binlog events must be generated for the transactions first. Under …

[Read more]
Showing entries 14973 to 14982 of 44965
« 10 Newer Entries | 10 Older Entries »