MySQL, Alter Table, and How to Observe Progress

August 5th, 2009

Network GearToday we had to do a very large alter table on some production data.  The table in question is big. 47 million rows big.  We have to make some changes to drop a column and change some indexing to support our application.  Fine, ALTER TABLE blah blah blah.  But how do we keep an eye on the progress of the alter?

There’s nothing in the documentation for MySQL that speaks to a method, nor does any google searching pull up anything (except for the one InnoDB file per table patch.)

So what’s a clever systems administrator to do?

I looked at the output of lots of status commands from MySQL, and finally I came across something useful in the InnoDB engine status output.  I noticed that there was an entry in the TRANSACTION section that speaks to the undo log entries.  I noticed that after several hours of our ALTER TABLE running that the undo log entries value was up around 33 million.  And then it occurred to me that since InnoDB does row-level operations, that this value might correspond to the number of rows that have been operated on throughout the process of the ALTER:

---TRANSACTION 0 2769988559, ACTIVE 53210 sec, process no 4115, OS thread id 1157654880 inserting, thread declared inside InnoDB 91
mysql tables in use 2, locked 2
111667 lock struct(s), heap size 13580272, undo log entries 33707735
MySQL thread id 948913367, query id 1662722204 localhost root copy to tmp table

So I wrote some bash.  And some awk.  And some perl, and I made a hacky little one-liner script to dump out the rate of change, the average rate of change, the % complete, and an estimate (based on average rate of change) as to when the query might be complete.

That script is below, and you are welcome to it.  I have yet to wrap it in more clever perl to dump out an actual status bar, but I’m happy with it, and hopeful that this is a meaningful way of keeping an eye on the rate of change, and the progress of ALTER statements.

The script:

#!/bin/bash
(while(true); do  \
(mysql -e 'show innodb status \G' | grep undo\ log\ entries ; sleep 1 ;  \
mysql -e 'show innodb status \G' | grep undo\ log\ entries ) |    \
egrep '[0-9][0-9][0-9][0-9]' |awk '{print $10;}' ; done ) | \
perl -e '$t = ROWS_IN_TABLE; while(1) { \
$n ++; $nn; $a = <>; $b = <>; $nn += ($b-$a); \
printf "Rate: %d, avg: %d, %0.3f%% complete, done in %d sec\n", \
$b-$a, $nn/$n, ($b/$t)*100, ($t-$b)/($nn/$n); }';

I hope you find this tool useful.

It took a LONG time for the query we performed to run, and it was very helpful to have this to gauge the time it’d take.   The moving average is not the best for long-term accuracy; restart the script periodically for better views (and wait for ~100+ trips through the loop.)

It was within three minutes of accurate.  It look a little longer than the script indicated (log undo entries was greater than the # of rows, but not by more than a small percentage (less than 0.01%.)  The total query time was 22 hours, 9 minutes, and 33 seconds.  So it was off by only 1 hundredth of a percent.

This is only valid for ALTER TABLE, but appears VERY useful. :)

WOOHOO!

MySQL, Ramblings , , , ,

The Opening is Tonight!

June 4th, 2009

So the opening for my show is this evening.  Wow, I’m excited.

Ramblings

My Work – an Exhibition of My Photography

May 21st, 2009

Utilikilts in JuneSo in June, I’m having my first art opening.  That’s exciting!   Over the last half-year I’ve been talking to the folks at Utilikilts about whether they’d be interested in seeing my works in their store for Art Walk.  They expressed interest that yes, indeed, they would like that.  So we talked, and figured things out, and now I’ve got an opening coming up.

This collection of works ranges over a few areas of interest for me: Burner Culture, People, and some other pieces.   Please come see my work next month, on June 4th for Art Walk at the Pioneer Square Utilikilts store.  There will be a live DJ and drinks to be had.

It’s very exciting, and I’m looking forward to it.  I hope to see everyone there.

Ramblings

Thoughts from MySQL Conf, Oracle’s Acquisition of Sun, and Meeting New People

April 23rd, 2009

I attended MySQL Conf, and it’s been an neat conference.  The most surprising thing was the news was the purchase of Sun by Oracle.  This sounds to me like a play for a solid vertically integrated market for Oracle.  I can appreciate that — they get Sun’s hardware and OS skills, they bring their own DB services to the table, and they get a lot of community with MySQL.

Lots of people have spoken about their fears that Oracle will suffocate MySQL, but I don’t think they’ll do that.  I think that Oracle realizes how centrally important to the web community that MySQL is.  I do think they’ll try to sell Oracle to high-volume MySQL sites, and that makes sense.  And I think they’ll continue MySQL to bring DB share under the Oracle roof.

MySQL is hugely popular, it wouldn’t make any sense to throw away that good will.

Other things from the conference have been that I’ve run into people I haven’t seen in a while, and I’m learning things.

One of the most interesting talks I went to was Rockyou’s talk about how they built their federated platform for supporting their Facebook applications.    Very neat to see their approach, especially since we’re buidling our own sort of Facebook applications, specifically Bejeweled Blitz.   Good times.

I met the photographer called Julian Cash, a very nice guy located in San Francisco.  He did a light painting portrait of me, which was fun.   We talked about various things for a while, and he talked to me about his project that he’s working on.  More to come later.

Today is the last day.  Things are winding down, and I’m preparing to go home.

MySQL, Photography, Ramblings, adventure

Northwest Science Fiction and Fantasy Convention (Norwescon) Shoot

April 15th, 2009

KR-2This past weekend was Norwescon, a sci-fi/fantasy convention.  It was awesome.   I put on a shoot for free out of my room, and I got a good turnout, and I had a lot of fun.  It was a good experience, and good practice.  Next year, I know some things I’ll do better.

I got a lot of good feedback, and pleased participants.  Woohoo.

I think it’s important to do things like this to give back to the community — to let people come if they want to have a photo made, and share in a creative process.  The best photos were those when the subject played along, and had ideas about what to do.  I like it when it’s a collaborative project.

Anyway, enjoy.  Click the image for the flickr.

-Gabriel

Photography, Ramblings

The Long Winter

March 23rd, 2009

Looking for the LightIt’s been a long time since I’ve updated this thing. Lots of changes, some photos. Good times. ;)

Christmas has come and gone, thank goodness. The holidays aren’t for me. Winter is over, and I’m glad. But it’s been too long without updating. Without creating. Without feeling good about things. It’s time for that to stop, and for things to get back on track.

So, I’ve got some things cooking that’ll be good. I have a strong lead on a show in the summer (more to follow later), some leads on good ideas/concepts to push myself, and I’m biking to work now. 11 miles in the morning is good fun.

But where to go from here, that’s the thing. I have ideas, but to make them real…

Photography, Ramblings

Digital Rights, New Media, and Copyright Infringement

November 19th, 2008

I discovered today that a work of mine has been infringed upon.   Let me back up, and tell a story.  Long ago, months, maybe sometime last year, nowpublic.com (one of their interns, anyway) approached me about using a photograph in my flickr stream in one of their projects.   I told them no, and that they should never look to my photostream as a source of images.  I’m not interested in licensing them my photographs for merely attribution.  That’s why my flickr stream is set at “All rights reserved.“  Not some rights, all of them.

I understand that it can be a hard thing as a new media company to figure out what images online can be used, and the ones that can’t.  But I expect, and I demand that everyone who is going to do this operate as professionals. And being a professional means doing the work to figure out the source and the license terms of the images you want.

It’s very easy in the new web 2.0 world to hire an intern, and tell them, “Hey, go browse flickr for images that look like X, Y, and Z.”  Super easy, and you’d think, super effective at getting great content.  Given how many images that flickr has in their databases, you’d be right.

The image at right of the garlic is the one that NowPublic copied to their servers. I am an artist; my time and particular point of view are what make the things that I create have value.   I even have it available for licensing, but unless you speak to me *FIRST*, you’re stealing my work, and my effort, and my intellectual property.

Here’s what they did:  The copied my image, and put it on their server, in the hopes that I’ll either be overjoyed to have someone accept me, or at least that I’ll accept their use.   But that’s not the case.  My art is meaningful to me, and it’s not free for anyone to take and use.

Infringing act

Being new media means doing new things, creative things. But it also means respecting content creators and their rights.  NowPublic doesn’t appear to do this.  I’m really disappointed in them, and I know that I’m not going to think of them positively when asked about them.  How hard is it to ask first?

-Gabriel

Photography, Rants and Raves

Website updates, house cleaning, and administrivia

November 11th, 2008

I’ve made a few changes to the blog: I’ve switched themes to something that I think fits better with what I want htis to be, and I’ve updated my photography website to have a better portfolio set of images.  Go take a look.

Ramblings

Hive-Mind’s Halloween Party

October 27th, 2008

This weekend I went to the Hive-Mind Halloween party.  It’s a pretty cool scene, and the money raised from it goes to support local arts organizations and other charities.  It’s money for a good cause, and it’s a great time.   I had a good time catching up with people I hadn’t seen in a while, and taking lots of pictures of people.

I played around more with a hand-held shoot-thru umbrella setup there.  It worked well, and it went very well with my steampunkish costume.   The results, and full photo set can be see on my flickr page.

It was a fun time.

-Gabriel

Ramblings

More Casting

September 22nd, 2008

pentic of castingSo today I decided to do another pendant.  And it went well.  I’m happy with my progress, like I’m gaining skill (like I want.)

Metal flows through the mold
Flowing swiftly ’til it turns cold
Shapes cast from a fleeting master
I see you freed in your sprue tree
Polished to a shine
Cast metal, frozen solid.

I’m thinking that I’m going to try sandcasting as an approach for doing lots of these.  I takes a lot of time to prepare these as one-offs of wax, to sprue them, invest them, burn them out, and pour them.  2-3 hours each.  I think by sand-casting, I can get that down to 30 minutes for batches of ten.  That’d be awesome.

Hopefully in a couple weeks, I’ll have the materials on hand to do that.  See you soon…

Burning Man, Photography, Ramblings, Things I made, casting