THE WORLD DISCUSSES #PYTHIAN ON TWITTER. HAVE A QUESTION? USE OUR HASHTAG AND ASK AWAY.

MMUG: Community, Education, and Good Company in Malta

So, we’re coming up on that time again. When I moved back to Malta in order to work for Pythian one of the things that I wanted to do was to involve myself more in the community. Currently, I’m doing this by trying to keep an active blog with tips and tricks, good standard knowledge, and just overall trying to enlighten people. I’m also doing this by organizing a MySQL User Group here in Malta.

We’re set to have our 2nd meeting this coming Thursday, the 28thof August, in Ta’ Xbiex where we have graciously been donated a board room and projector (and parking space, luckily) for use. I’m trying to get one of our members to give a session about security (not only on MySQL, but also on the OS level to secure the process), and I know there is work being done on a presentation on MySQL Cluster, which I personally find very interesting and can’t wait to see.

In this second meeting, we’ll again focus on general best practices and free discussions, in order to share our knowledge as much as we can. The last meeting was in Mellieha and it was a success — we had a good turnout and some very interesting discussions. Darren, one of our members, blogged about our meeting here and so did I in one of my previous posts.

Read the rest of this entry . . .

mysqlbinlog Tips and Tricks

So, you have a binlog. You want to find out something specific that happened inside of it. What to do? mysqlbinlog has some neat features, which I thought we would look at here.

I should first explain what mysqlbinlog really is. It is a tool that lets you analyze and view the binlogs/relaylogs from mysql, which are stored in binary format. This tool converts them to plaintext, so that they’re human-readable.

For the first tip, let’s start with the --read-from-remote-server option, which allows you to examine a binlog on a master server in order, perhaps, to dump it onto your slave and compare master/slave logs for potential problems*.

$ mysqlbinlog --read-from-remote-server -uwesterlund -p mysql-bin.000001 -h 127.0.0.1 -P 3306 | head -5
Enter password:
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#080815 19:25:23 server id 101  end_log_pos 107 	Start: binlog v 4, server v 6.0.5-alpha-log created 080815 19:25:23 at startup

Pretty useful!

Now, let’s assume we have a binlog that is 94 lines long*:

Read the rest of this entry . . .

Adding a Unique Constraint on a Table with Duplicate Data

After I moved back to Europe and Malta in order to set up our operations here, I was approached by a old friend of mine who wanted to know how to add a UNIQUE constraint and remove duplicates on a table, while keeping the newest records. He had been trying with ALTER TABLE but ran into problems as the older values were taken.

So, to help him out, I first solved it based on his original idea, and then figured I would post a small note about the solution here.

So, let’s say we have the following structure . . .

sql01 blogs> SHOW CREATE TABLE post1164\G
*************************** 1. row ***************************
       Table: post1164
Create Table: CREATE TABLE `post1164` (
  `a` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `b` varchar(5) DEFAULT NULL,
  `c` varchar(5) DEFAULT NULL,
  PRIMARY KEY (`a`)
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

. . . with a small amount of data in it:

sql01 blogs> SELECT * FROM post1164;
+---+------+------+
| a | b    | c    |
+---+------+------+
| 1 | a    | a1   |
| 2 | a    | a2   |
| 3 | b    | b1   |
| 4 | c    | c2   |
| 5 | b    | b2   |
| 6 | c    | c1   |
+---+------+------+
6 rows in set (0.00 sec)

Now, if I were to use his original SQL, I would get a result similar to this:

Read the rest of this entry . . .

First MMUG Meetup in Malta

So, the Malta MySQL User Group has had its first ever meet-up today, and it was a success! When organizing it, I had no clue how many people would show up, people have said “yes” and then changed to “no”, and vice versa.

Anyway, so the morning came, and I sent out a few confirmation emails, and it suddenly dropped down to just three of us, which was a shame. Anyway, around 5pm, I noticed that there was four more that had just said they wanted to attend. Unfortunately, one of those dropped out, but it was still a great turnout.

This is a great opportunity for us to promote MySQL use in Malta, as well as share experience and knowledge. Also just to network a bit.

So, this time, for meeting #1, we met up outside a local bank, and walked to Il-Mithna, which is a local restaurant. In this picture, there is the first core group of local user group members, all happily gathered and just about to start our discussions.

Malta MySQL User Group

Read the rest of this entry . . .

MySQL Back to Basics: Analyze, Check, Optimize, and Repair

It felt like the right time for us to look back at some useful commands for table maintenance that some of us may not have mastered as much as we might like to think.

In my post about gathering index statistics, I referred to OPTIMIZE TABLE, ANALYZE TABLE, and REPAIR TABLE — but I never explained in depth what the different commands do, and what the differences between them are. That is what I thought I would do with this post, focusing on InnoDB and MyISAM, and the differences in how they treat those commands. I will also look at different cases and see which one is right for in each case.

Read the rest of this entry . . .

MySQL User Group in Malta

That’s right. MySQL now has a user group in Paradise.

I am always looking into connecting with other MySQL professionals, to share the laughs and tears, and to enjoy what we love working with every day, MySQL. I have always wanted to bring us all together, and I thought that this would have a good chance of doing so. Since I live in Malta, this made for the perfect location for it. If you live in Malta, or perhaps in Sicily or Tunisia, and want to take a trip, please do join us at our first meeting.

We will be having our first meeting in Mellieha, and please RSVP to me personally via email, westerlund (at) pythian.com if you want to attend. The date is set for Thursday, July 31st at 6pm. We will discuss the current use of MySQL, its future, and whatever else comes into mind. I myself would love to hear usage stories for our first meeting, so we all get an understanding of how MySQL is used in Malta and environs.

I will make sure there are some refreshments to be had.

Let’s keep ourself educated and aware of how other people solve problems that we all sometimes encounter, as well as their interesting technical solutions. And let’s have some fun doing so!

MyISAM Statistics Gathering

So, how does one gather statistics on indexes? With InnoDB it’s one thing, with MyISAM it’s another thing. This post however, will focus on MyISAM. There are various ways, each having their own drawbacks and positive sides.

What about ANALYZE TABLE? It’s great — very fast in InnoDB. But with MyISAM a lock occurs while scanning the table.

OPTIMIZE TABLE? Still relatively quick with MyISAM, unless the table in question is huge. InnoDB requires an ALTER TABLE — it might take forever, depending on the server configuration, as OPTIMIZE TABLE for InnoDB maps to a ALTER TABLE tableName ENGINE=InnoDB

We all know how ANALYZE TABLE, REPAIR TABLE, and OPTIMIZE TABLE work with MyISAM. However, there’s a less explored way, for MyISAM — the myisam_stats_method.

Read the rest of this entry . . .

On Joining Pythian

I’ve joined Pythian and thought I would present myself and give my initial opinions on Pythian as employer.

First off, I should mention that although I’ve been working with MySQL for a long time, I’ve never actively gotten into the blogging in the past, but all of that is about to change. I’ll be posting about research and problems I encounter, much like everyone else, and I hope I’ll be able to shed some light on issues that other people run into.

I just transferred to Pythian Europe from my old employer in the US, because I was tired of the American life and wanted to move back to Europe for personal reasons, and during that process I came in contact with Pythian and realized that this company is everything I wanted in an employer, plus I get to work in the services sector, which is something I really enjoy. Either way, I decided to come on board, and now I’m on my way to the corporate head office in Ottawa for initial training, and then I go back to Malta, where I am based. (Finally, back at the Mediterranean – don’t take me wrong, I loved southern California, but it’s just not the same thing as Malta.)

So far, I really enjoy everything that Pythian has, excellent co-workers, great spirits, nice work environment and fun challenges. Plus this will be my first time ever in Canada, so that’s something I will show too, I just hope it’s not that cold during July.

–Nicklas Westerlund.

Start NowWith Pythian - database design, management and emergency handling capabilities...

Live Updates

pythian: @ghemant @pythian love your #hemantgiri
more



Testimonials

  • Serge Racine

    DBA, Brookfield Energy

    We are very satisfied by the service given to us by Andre and Shakir in support of our recent data quality and reorganization initiative.... more



Social links powered by Ecreative Internet Marketing