Friday, June 23, 2006

Driving to FrOSCon

I am ready to leave for the FrOSCon Conference, taking place on Saturday and Sunday in St. Augustin/Germany.

Here's the program that contains many MySQL related sessions.

I hope to meet many MySQL people there ;-).

Sunday, June 11, 2006

Information_schema query taking more than 7 minutes

The biggest current problem that I know in the MySQL servers is the performence of information_schema. This is reported as bug 19588:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1829 to server version: 5.0.22-max-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> SELECT TABLE_SCHEMA,
-> sum((DATA_LENGTH + INDEX_LENGTH) / (1024 * 1024)) as size_mb
-> FROM information_schema.TABLES
-> GROUP BY TABLE_SCHEMA
-> HAVING size_mb > 10
-> ORDER BY size_mb DESC;

...

xxx rows in set (7 min 34.71 sec)


Even though this server hosts a lot of data - more than 7 minutes for this query is tough.

www.mysql.com higher PageRank than Google

Google offers a little Toolbar that provides additional information about the displayed website, including the PageRank value that indicates how "important" the website is in Google's eyes (and that's said to be used to calculate the relevance in Google searches).

Here are some values that I looked up:

www.mysql.com: 9/10
www.planetmysql.org: 8/10
www.google.com: 8/10
www.microsoft.com: 9/10
www.yahoo.com: 9/10
www.oracle.com: 9/10
www.postgresql.org: 8/10
www.amazon.com: no value
www.phpmyadmin.net: 8/10
www.php.net: 9/10
www.wikipedia.org: no value
www.novell.com: 8/10
www.redhat.com: 8/10
www.orf.at (Austria's national TV broadcast station): 7/10
www.db4free.net: 6/10
www.freesql.org: 5/10 (but currently no content)
www.freemysql.net: 4/10
www.mpopp.net: 4/10

There's only one website that I've found with a value of 10/10: www.apple.com.

However, it's great to see that the relevance of MySQL's website is among the highest of all websites of the world.

Tuesday, June 06, 2006

Knoppix 5.0.1 available

Today I have downloaded the brand new Knoppix 5.0.1 DVD and played a bit around with it.

It looks quite nice, although some of the packages are very up to date and others are quite old. MySQL comes with 5.0.21, so there's probably no distribution with a more recent MySQL version at the moment.

PostgreSQL is included with version 8.0.4, while the current version is 8.1.4 (and the latest version of the 8.0 tree is 8.0.8). Apache comes with versions 1.3.34 and 2.0.55, but only Apache 1.3.34 is configured to start with PHP and that only with PHP 4.4.2, which is the most disappointing aspect that I found.

Saturday, June 03, 2006

Multiple SP call crash to be fixed in MySQL 5.0.23

There was this bug that I wrote about earlier which caused certain Stored Procedures to crash when they were executed more often than once.

I noticed in the bug report and in the change log that this bug will be fixed in MySQL 5.0.23.

Goodbye anger, hello fun

I just saw a Microsoft commercial video clip using the slogan

"Better and more simple Visual Basic - goodbye anger, hello fun"

What do they want to tell us? Does that mean, the former version of Visual Studio/Visual Basic caused anger? Do they worsen their old product to make advertising for the new one?

My next thought would be - how will they advertise when the next version comes out? Will they again say, that the now current release causes anger or something similar?

I don't think that's good advertising.

Thursday, June 01, 2006

How I work

I think it was Brian Aker who got this "How I work" series started and it's a pleasure for me to join in and tell you something about how I work.

Actually, it's only half a month since I've been working for the web development team of MySQL, so some things might still be subject to change. But most things are very likely fixed, so here they are ...

My working PC is an Athlon AMD64 3200+ with 2 GBs RAM and two 250 GB hard drives. Currently it's running SuSE Linux 10.0, preferably with KDE and I'm using the ext3 file system. However, I consider switching over to Fedora not too far from now (maybe in early October, when Fedora Core 6 is released).

Formerly I worked most of the time with Windows, but delegated some server tasks (file server, print server, web server, database server, ...) to Linux - which always used to be SuSE, so I'm still most familiar with this distribution. I used to do a lot with YaST (SuSE's configuration tool), but since I started my job with MySQL and with it started to extensively use Linux, I'm doing much more on the command line and therefore become more independant of GUI tools. More about that later.

My email client is currently "Kontakt", one of KDE's standard email, contact and scheduling applications. I'm not yet sure if I hold on to this, since there are some issues that don't work like I'd like it to (however, I didn't spend much time with this application - so maybe it's because of me ;-)).

For development, I currently use kvim, but though I often used the vi editor to make modifications on files, I'm not very sure if I'll like it for more complicated development tasks. Maybe I'll look around if I find a good PHP plugin for Eclipse (which I preferably used for Java development so far - one of the best IDEs, I guess). If you can recommand something like this, please let me know!

My preferred web browser is Opera. The big advantage compared to Firefox is (in my opinion) that I don't need to install plugins to get everything I need. It's very comfortable to work with!

But of course, I also need different browsers, and some browsers require different operating systems - therefore I use VMWare Server. Unfortunately, I don't have a Mac available yet, but this might also change ;-).

As I already mentioned - I do a lot at the command line now. One of my favourites is
find -name '*' -exec -q [regexp] {} \; -print

which allows me to find all files in the current directory (including subdirectories) where a certain regex pattern occurs. This is extremely helpful mostly now at the beginning of my web developer job to find the code sections that I'm looking for.

Another useful thing I've learned recently is to use the tar compression command not only for decompressing (I actually used that for a while), but also for compressing files and whole directory structures.

And finally, I learned a lot about Subversion. Actually, I have used CVS (and for a short time also Subversion) before, but on quite a low level - so this is also an important improvement.

And of course - I'm learning more and more every day, which is one of the most pleasant aspects of my job.

My working hours are mostly in the evening and during the night, which provides several advantages. First of all, my colleagues live in different parts of the world, so it's easiest to catch them at these times and second, I'm a night person. I used to sleep in the morning (so, right now is an exception - it's currently 10:20 a.m., that's when I'm usually deeply asleep) and can do some other things during the afternoon (and do little job tasks in-between) - to dedicate myself to the job starting from the late afternoon or early evening, mostly until 3 or 4 o'clock in the morning. Another big advantage is that during the evening and night, it's very calm and there's no danger of being disturbed by anyone ;-).

Did I forget something important?

FrOSCon Conference in St. Augustin/Germany from 24th to 25th June

I'm looking forward to visiting the FrOSCon Conference in St. Augustin/Germany from 24th to 25th June and to meeting some fellow MySQL Community members and colleagues.

The MySQL related events are:

* MySQL Administration - Backup and Security Strategies on Linux by Lenz Grimmer

* MySQL Cluster: an introduction - A journey into High Availability by Geert Vanderkelen

* Pivot tables in MySQL 5 - creating cross tabulations with MySQL 5 stored routines by Giuseppe Maxia

* The MySQL Business Model - Where and How we Thrive by Lenz Grimmer

... and of course there are many more events that are related to MySQL indirectly (like PHP, Java, Typo3, ...).

Filling table with prime numbers

First of all many thanks to Dean Swift, Carsten Pedersen, Kai Voigt and Kristian Köhntopp for providing me with this example and allowing me to blog about it.

This origins from a stored procedure exercise that a group of students did which ended up in an optimization competition. It's about a table that should be filled with prime numbers - up to a pre-defined bound - by a stored procedure.

So here's the basic solution:

mysql> DELIMITER //
mysql> CREATE DATABASE sieve //
Query OK, 1 row affected (0.00 sec)

mysql> USE sieve //
Database changed
mysql> CREATE TABLE sieve (
-> id INT PRIMARY KEY
-> ) //
Query OK, 0 rows affected (0.06 sec)

mysql> CREATE PROCEDURE sieve (max INT)
-> BEGIN
-> DECLARE l0 INT;
-> DECLARE l1 INT;
-> TRUNCATE sieve;
-> SET l0=2;
-> WHILE l0
-> INSERT INTO sieve (id) VALUES (l0);
-> SET l0=l0+1;
-> END WHILE;
-> SET l0=2;
-> WHILE l0
-> SET l1=l0*2; # delete from first multiple
-> WHILE l1
-> DELETE FROM sieve WHERE id=l1;
-> SET l1=l1+l0;
-> END WHILE;
-> SET l0=l0+1;
-> END WHILE;
-> END //
Query OK, 0 rows affected (0.00 sec)

Here's some further information, if you want to play with optimizing this stored procedure:

Our colleague, Philippe Campos, suggested removing the inner loop and replacing it with a modulo operator. (DELETE FROM sieve WHERE (id%l0)=0 AND id>l0) This increased speed. He then suggested batch inserts. This made it much faster. A student suggested batch insert of odd numbers to the memory storage engine. The former is cunning and the latter opens much scope for optimization beyond the algorithm of the stored procedure.

By what ratio can you improve the basic implementation? Do indexes help or hinder?


So what's your best solution?

Enjoy!

From Oracle via MS SQL Server up to PostgreSQL or MySQL

This morning I browsed through a training course book (from one of the largest Austrian training providers) and found the description for a SQL course which I think sounds really nice. Translated to English, it says about this:

"You will learn to know dialect independant SQL, which can be used in almost all database systems without major changes - from Oracle via MS SQL Server up to PostgreSQL or MySQL."

I really like the way how they've set the priorities :-).