MySQL Enterprise Monitor offers a tool called "Query Analyzer"
(QuAn). QuAn sits between any client app and the MySQL server and
logs every query and its runtime statistics. A very cool tool for
analyzing your SQL. More information is available here.If you identify a query, that needs some
improvement, sometimes it is hard to identify the source of that
query as well. With hundreds of different PHP scripts for example
it is not easy to know, which one issued the query, that you want
to modify.A good way to achieve this is adding C-style SQL
comments. Let's look at an example: SELECT * FROM mytable …
The latest from the MySQL community
Ideas, releases, practical guides, and perspectives from the people building with MySQL.
I’ve released version 1.1.6 of the Better Cacti Templates project. This release includes a bunch of bug fixes (but not all of them!) and two new sets of graphs. One set is for disk I/O on GNU/Linux, and the other is a new set of templates for OpenVZ. I’m looking for feedback on both of those. This release also has a bunch of code-level features: much better test coverage (hooray!), and a refactored ss_get_by_ssh.php that makes it much easier to create new graphs and templates. The SSH-based templates also take advantage of the same caching as the MySQL templates, which makes them a lot more efficient.
There are upgrade instructions on the project wiki for this and all releases. There is also a comprehensive tutorial on …
[Read more]
iostat is one of the most important tools for
measuring disk performance, which of course is very relevant for
database administrators, whether your chosen database is
Postgres, MySQL, Oracle, or anything else that runs on GNU/Linux.
Have you ever wondered where statistics like await (average wait
for the request to complete) come from? If you look at the disk
statistics the Linux kernel makes available through files such as
/proc/diskstats, you won’t see await there. How does iostat
compute await? For that matter, how does it compute the average
queue size, service time, and utilization? This blog post will
show you how that’s computed.
First, let’s look at the fields in /proc/diskstats. The order and location varies between kernels, but the following applies to 2.6 kernels. For reads and writes, the file contains the number of …
[Read more]It may sound like a dramatic number, and that’s because it is. One thing that is enjoyable about working on beta applications is finding new solutions and better methods to improve the user experience. The original method for displaying the recent addition of overview analytics data in the beta version of Kontrollbase was to run [...]
One of the most widely discussed topics to go around the tech industry last year was the Oracle acquisition of Sun and what this meant for the MySQL database. This topic held up the merger with the US DOJ and currently has it stalled in the EU commission.
One of the primary forces behind these hold ups is a series of FUD articles written by Monty Widenius, the most recent just a few days ago. Monty has a huge following so whenever he writes up one of these articles it gets huge circulation and riles up the Slashdot and LAMP crowds.
I think that the open source community should be very skeptical about anything written by Monty on this topic, and should start looking at the big picture of what this merger means for themselves and the various players involved.
I don’t know why I haven’t been seeing many serious rebuttals to …
[Read more]It’s New Year’s Eve, a date that should strike terror into the hearts of many, because tomorrow a bunch of their queries are going to fail.
Queries to “find all birthdays in the next week” and similar are always a nightmare to write. If you want to see a bunch of examples, go look at the user-contributed comments on the MySQL date and time function reference. This post is about a slightly saner way to do that. There’s still some nasty math involved, but a) a lot less of it, and b) at least the query will be able to use indexes[1].
So here’s my tip: instead of storing the user’s full birthdate, just store the month and day they were born. Try it. You’ll love it!
[1] Yes, I know Postgres can index a function. So this can be considered a jab at MySQL, which can’t.
Related posts:
- …
If you’d like some improvements to the Cacti templates (MySQL, Apache, Memcached, and more) I’ve been maintaining, please make your voice heard — either write to the mailing list, or post a new issue (or comment on an existing one) on the issue list. I’ve got a bunch of work underway, including a test suite for ss_get_by_ssh.php.
Related posts:
- Version 1.1.6 of Better Cacti Templates released I’ve
- Version 1.1.2 of improved Cacti templates released I’ve
- …
MySQL has a couple of sanity-check features to help keep you from doing dumb things.
- max_join_size is a configuration option for the mysqld server program. It throws an error if you write a query that the optimizer estimates will examine more than this number of rows.
- –safe-updates is a command-line option to the mysql client program. It throws an error if you write an UPDATE or DELETE without a) a WHERE clause that refers to an indexed column or b) a LIMIT clause. It also sets the max_join_size and select_limit variables.
The –safe-updates mysql client option actually sets three variables server-side. Let’s see the effects. First, the defaults:
…[Read more]Numeric types in MySQL have two varieties: - “precise” types such as INTEGER and DECIMAL; - the IEEE-standard floating point types FLOAT and DOUBLE. As a rule of thumb, the first group are for exact, “counted” quantities. The INTEGER types represent whole numbers, and DECIMAL represents “fixed point” decimal, with a preset number of places after the decimal point. Various widths of INTEGER are available in MySQL, from 8-bit TINYINT to 64-bit BIGINT. Calculations with integer types are fast, as they usually correspond to hardware register sizes. DECIMAL is commonly used for quantities like decimal currency where the number of digits of precision is known and fixed. For example, exactly counting pennies in two decimal digits. Computation with DECIMAL is slower than other types, but this is unlikely to impact most applications. In the other category are FLOAT and DOUBLE, which are the 32 and 64-bit IEEE standard types, which are usually …
[Read more]I’m on the MySQL conference committee again this year, so I’ll be reading and voting on your session proposals. My past experience is that reading 400 session proposals is a mind-numbing job, and I will be optimizing it to save my time. That means I will be scanning your proposals and deciding very quickly how to vote. I wrote before about how to submit a great proposal, but I’ve refined my opinion since then. Here are my suggestions:
- Write for two audiences: reviewers and attendees. Both of us want the same thing: to decide as quickly as possible whether your session will be good.
- Write a strong title/headline. Don’t know how? …