Skip to content

# Category: MySQL

MySQL related posts

## Working at Outbrain

MySQL June 21, 2013June 22, 2013

I’m starting my new position as Senior Software Engineer at Outbrain. While I’m still to fully grasp the scope of my work, I will be handling data on all things MySQL, Hadoop, Cassandra, Kafka, more, more and more, at very large volumes.

I find Outbrain a great supporter of community and open source:

- Open source solutions are highly preferred over commercial solutions
- Outbrain is an early adopter for many open source technologies
- Employees are encouraged to contribute back as much as possible to the open source community
- It is happy to pay for support from companies developing open source
- Outbrain is a major participant in the ILTechTalks initiative: free, volunteer, professional exchange of knowledge

I can already testify I will be working with very smart and knowledgeable people; I expect to learn a lot and of course contribute from my own knowledge and skills.

I’ve been in process with some other companies, I’d like to kindly thank those companies I’ve been in touch with for their good will.

## Easy SELECT COUNT(*) with split()

MySQL common_schema InnoDB June 8, 2013

The two conservative ways of getting the number of rows in an InnoDB table are:

- SELECT COUNT(*) FROM my_table:
  provides with an accurate number, but makes for a long running transaction which take ages on large tables. Long transactions make for locks
- SELECT TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=’my_schema’ AND TABLE_NAME=’my_table’, or get same info via SHOW TABLE STATUS.
  Gives immediate response, but the value can be way off; it can be two times as large as real value, or half the value. For query execution plans this may be a “good enough” estimation, but typically you just can’t trust it for your own purposes.

#### Get a good estimate using chunks

You can get a good estimate by calculating the total number of rows in steps. Walk the table 1,000 rows at a time, and keep a counter. Each chunk is its own transaction, so, if the table is modified while counting, the final value does not make for an accurate account at any point in time. Typically this should be a far better estimate than TABLE_ROWS.

QueryScript’s split() construct provides you with the means to work this out. Consider this script: Continue reading » “Easy SELECT COUNT(*) with split()”

## Converting compressed InnoDB tables to TokuDB 7.0.1

MySQL InnoDB TokuDB June 5, 2013

Or: how to make it work in TokuDB version 7.0.1. This is a follow up on a discussion on the tokudb-user group.

#### Background

I wanted to test TokuDB’s compression. I took a staging machine of mine, with production data, and migrated it from Percona Server 5.5 To MariaDB 5.5+TokuDB 7.0.1. Migration went well, no problems.

To my surprise, when I converted tables from InnoDB to TokuDB, I saw an increase in table file size on disk. As explained by Tim Callaghan, this was due to TokuDB interpreting my compressed table’s “KEY_BLOCK_SIZE=4” as an instruction for TokuDB’s page size. TokuDB should be using 4MB block size, but thinks it’s being instructed to use 4KB. Problem is, you can’t get rid of table options. When one converts a table to InnoDB in ROW_FORMAT=COMPACT, or even to MyISAM, the KEY_BLOCK_SIZE option keeps lurking in the dark.

So until this is hopefully resolved in TokuDB’s next version, here’s a way to go around the problem. Continue reading » “Converting compressed InnoDB tables to TokuDB 7.0.1”

## mycheckpoint revision 231 released

MySQL Development Monitoring mycheckpoint Open Source May 23, 2013May 23, 2013

A new release for mycheckpoint: lightweight, SQL oriented MySQL monitoring solution.

If you’re unfamiliar with mycheckpoint, well, the one minute sales pitch is: it’s a free and open source monitoring tool for MySQL, which is extremely easy to install and execute, and which includes custom queries, alerts (via emails), and out of the box HTTP server and charting.

This is mostly a maintenance release, with some long-time requested features, and of course solved bugs. Here are a few highlights:

- Supports MariaDB and MySQL 5.6 (issues with new variables, space padded variables, text-valued variables)
- Supports alerts via function invocation on monitored host (so not only checking alerts via aggregated data like ‘Seconds_behind_master’ but also by SELECT my_sanity_check_function() on monitored instance). See alerts.
- Supports single-running-instance via “–single” command line argument
- Supports strict sql_mode, including ONLY_FULL_GROUP_BY, overcoming bug #69310.
- Supports sending of pending email HTML report
- Better re-deployment process
- Better recognizing of SIGNED/UNSIGNED values
- Some other improvements in charting, etc.

mycheckpoint is released under the BSD license.

Downloads are available from the project’s page.

## opeark-kit revision 196 released

MySQL Development Open Source openark kit QueryScript May 7, 2013

This is a long due maintenance release of openark-kit. This release includes bugfixes and some enhancements, mainly to oak-online-alter-table.

oak-online-alter-table Changes / bug fixes include:

- Support for keyword-named columns
- Use of FORCE INDEX due to lack of MySQL’s ability for figure out the chunking key at all times
- –sleep-ratio option added; allows for sleep time proportional to execution time (as opposed to constant sleep time with –sleep)
- Support for chunk-retry (in case of deadlock) via –max-lock-retries)
- Fixed order of cleanup
- Fixed bug with verbose messages with non-integer chunking key
- Fixed bug with single-row tables (people, no need for this tool for single row tables :))
- Friendly verbose messages to remind you what’s being executed

oak-chunk-update changes includes:

- Verbosing query comment if exists (friendly printing of what’s being executed)

Continue reading » “opeark-kit revision 196 released”

## On compiling TokuDB from source

MySQL TokuDB May 2, 2013May 2, 2013

Sharing my experience of compiling TokuDB + MariaDB 5.5. Why? Because I must have this patch to Sphinx 2.0.4.

Note: I was using what seems to be the “old” method of compiling; quoting Leif Walsh:

> … We are looking at deprecating that method of building (MariaDB source plus binary fractal tree handlerton). It only really needed to be that complex when we were closed source.

I also tried the “new” method of compiling, which I couldn’t work out.

Here’s how it goes: TokuDB is newly released as open source. As such, it got a lot of attention, many downloads and I hope it will succeed.

However as stable as the product may be, it’s new to open source, which means anyone compiling it from source is an early adopter (at least for the compilation process).

#### Installation process

This is an unorthodox, and actually weird process. See section 6 on the Tokutek docs. In order to compile the project you must download:

- The source code tar.gz
- And the binary (?!) tar.gz
- And the binary checksum
- And the Tokutek patches
- And the patches checksum Continue reading » “On compiling TokuDB from source”

## Percona Live 2013 keynotes: followup questions and discussion

MySQL Opinions PerconaLive April 28, 2013

Here are a few questions remained open for me from Percona Live 2013 about things that have been said during keynotes; I will appreciate a discussion on comments. Here goes:

#### Question #1

> Brian Aker (HP) asks Simone Brunozzi (Amazon) what the underlying technology for DynamoDB is. Simone says can’t disclose. Brian says: “it’s MySQL!!”. Simone says: “can’t disclose”. Brian insists: “it’s MySQL!!”

Seriously? I will be very much surprised to learn that DynamoDB uses MySQL; it doesn’t make sense to me. Why would Brian Aker say that though? Did he just mean to tease Simone or is there something I just don’t get? Continue reading » “Percona Live 2013 keynotes: followup questions and discussion”

## common_schema booth on Percona Live 2013

MySQL common PerconaLive April 27, 2013
common_schema booth in Percona Live 2013 (someone left their soup on our table)
Allen Kinnard

Yay! I got a booth!

I confess it was mostly deserted. My hero Allen Kinnard, whom I’ve never met before, was kind enough to volunteer to occupy the booth.
So between him and me, both of course also looking to visit other booths and talk to people, the common_schema booth was only moderately attended.

Well, this was the DotOrg Pavilion: free booths for free & open source projects (e.g. OpenStack, PhpMyAdmin, etc.).
We both did our best to explain common_schema to the visitors.

The booth was actually titled “common_schema & openark-kit”. However I don’t recall that anyone asked me about openark-kit. Most were just interested in what common_schema was. I get that openark-kit is well known by now to many.

We did not have so many visitors, which played well with our occasional absence. But this was a last moment arrangement. In future events I may try to get things on top and have an army of volunteers to help me out (and I hope that by next time common_schema is widely used).

Now for the criminal department: practically all other DotOrg booths came prepared, with printed material, giveaway stuff and the like. We were like way beyond “the minimalist”. We were “the poor and the pitiful”. So I asked Kortney if she could arrange me some decorations (pulling some strings – yeah!). We were thinking a bowl of candies or something. Eventually she brought a few dozen candies (no bowl) and laid them nicely on the table; very nice touch! Good mixture of colors, nice wave design.

And guess what? Visitors actually thought they may take one of our candies! Oh, I schooled them.
But on Wednesday, when we arrived to the booth, a horrid sight stroke us: someone stole (and probably ate) 80% of our candies!
Well, I hope you’ve got bellyache, and next time you should know there will be surveillance, candy-thief!

## Slides from my talk: common_schema, DBA’s Framework for MySQL

MySQL common_schema PerconaLive April 26, 2013

I’ve just uploaded the slides from my talk: common_schema: DBA’s framework for MySQL

My talk was well attended, and I was fortunate to have a warm and engaged audience. Thank you to all those who attended, and thank you for those who provided feedback! Was happy to be able to present my work a great group of people.

You can find my slide either on Percona Live’s website, or on Slideshare, as well as embedded right here.

I set two aims to my talk:

1. To have the audience know how to download and install common_schema (Check!)
2. Have everyone in the audience find one tool from common_schema that will make their day better. Quick raise of hands at the end of presentation: Check! All hands are up!

As I’ve noted following a question, rdebug is still in alpha. It modifies one’s routines in such way that does not alter the routine’s behavior, except:

- Affecting the value returned by ROW_COUNT() (I have no immediate solution to that)
- Also affecting result of LAST_INSERT_ID() (I expect to have this solved).

Thank you again; give common_schema a try. Best ways to support: submit bug reports, ideas, and above all: spread the word. common_schema for world domination!

common_schema 2.0: DBA's Framework for MySQL from Shlomi Noach

## Impressions from Percona Live 2013

MySQL community PerconaLive April 26, 2013

At the airport, trying to sum up my impressions from Percona Live 2013 conference in Santa Clara.

Woo! Hard to sum up four excellent days. Shall I review the great talks I’ve been to? The keynotes? The well organized events?

You know what, skip it. There was ONE thing that overshadowed everything. It was the ONE thing for me that was the pure essence of the conference and its greatest joy:

Meeting and talking to a great many great people!

I was fortunate to meet up with so many people; none that I planned; things just went in such way that I engaged in so many conversations with so many people. I found myself talking about hamsters, peacocks, living in the village, living in the city, working from home, commute, relocation, working with your spouse, life in Israel, life in Argentina, prisons in the US, having many children, gun control, politics (heaven forbid!), fruit, vegetables, breakfasts, open source, community, buying (non-expensive) presents to your kids, new ventures, zen, philosophy, capitalism, socialism, books, being who you are, weddings, Java, scripting, NoSQL, how to contribute to an open source project, … the list goes on.

I was “adopted” by the PalominoDB team at Pedro’s, crash-partied on Pythian fellows, talked technical (or non technical) with Tokutek guys, meeting up with Oracle people (finally I get the faces behind the names!); the companies do not matter, I’m just throwing in names. The people are awesome! Representing their companies on the technical side, and being purely interesting people on the personal side, I met with men and women from all over the community. Apologies: impossible to list all nor account for!

It’s great to have a place and time where we all meet together.

The bottom line? I am fortunate to have my current profession: I enjoy my work, and the people I meet are fantastic and of the highest quality!

Thanks all with whom I’ve met, and for all of those with whom I haven’t had the chance to speak: see you next time!