Skip to content

Rename a database in MySQL

Ever tried to rename a database in MySQL? Obviously not.

Why not? MySQL does not support renaming databases. Funny, eh?

They once tried to implement this feature but failed and removed the code again. Note the sudden major feature shifts in minor releases.

So, how to rename a database? Dump the database, create a new database and import the dump. Both steps can be executed together:

mysqldump old_database | mysql new_database

About this new MySQL Emulation Layer in PostgreSQL 9.0

This blog post of mine about the new MySQL Emulation Layer in PostgreSQL 9.0 was (more of less obvious) an april joke. Most readers have guessed right.

On the other hand the idea, that this joke is based, is very real: during the last conferences and exhibitions which I have attended, a lot visitors asked us (the PostgreSQL booth staff) about the future of MySQL.

Guess what - we don't know! Please ask Larry ;-)

The next question was usually about porting a MySQL database to PostgreSQL. Many companies selling products with MySQL inside are irritated - and frustrated: "Can i still buy a MySQL license in a year or two?" - "And if yes: how many bucks will Oracle request for this?". "Will Oracle still offer support or will they try to convience everyone to use Oracle database?" At this point many companies start to look for some other database - and PostgreSQL is there, happy to help.

I would like to thank David Fetter at this point, he did the proofreading for my post.


Continue reading "About this new MySQL Emulation Layer in PostgreSQL 9.0"

PostgreSQL 9.0: Includes the new MySQL Emulation Layer

PostgreSQL 9.0.0, released today, contains the MySQL Emulation Layer.

To enable this feature, set the mysql_compatible option GUC to "on".

postgres=# SELECT * FROM pg_settings WHERE name = 'mysql_compatible';
-[ RECORD 1 ]----------------------------------------------------------------
name         | mysql_compatible
setting       | ON
unit            |
category     | Version AND Platform Compatibility / Other Platforms AND Clients
short_desc | Enable MySQL Emulation Layer
extra_desc |
context       | backend
vartype      | bool
SOURCE        | DEFAULT
min_val      |
max_val     |
Continue reading "PostgreSQL 9.0: Includes the new MySQL Emulation Layer"

Support your database!

Happened on IRC, just minutes ago:

22:35:09 -!- michi7x7 has joined #postgresql
22:35:14 < michi7x7> hi all
22:35:44 < michi7x7> i have a problem with a mysql-query, but #mysql is full of mysql-lover-noobs

Users start asking the PostgreSQL-guys for MySQL-support. Times are changing ;-)

MySQL: SQLSTATE[HY000]: General error: 3 Error writing file '/tmp/xyz' (Errcode: 28)

If you run MySQL and this error occurs:

 SQLSTATE[HY000]: General error: 3 Error writing file '/tmp/MYh0VgDS' (Errcode: 28)

then check if your server isn't using the famous "overflow" filesystem for /tmp, limited to 1 MB space.

The MySQL error message is - as usual - misleading and non-descriptive.

There are many other possible causes for this error code, so this one here might just be a hint.

MySQL creates rows out of nothing

After issuing a REPAIR TABLE:

 mysql> repair table search_archive_count_checked;
+----------------------------------+--------+----------+----------------------------------------------+
| Table                            | Op     | Msg_type | Msg_text                                     |
+----------------------------------+--------+----------+----------------------------------------------+
| xxx.search_archive_count_checked | repair | warning  | Number of rows changed from 335540 to 365874 |
| xxx.search_archive_count_checked | repair | status   | OK                                           |
+----------------------------------+--------+----------+----------------------------------------------+
2 rows in set (36.75 sec)

I'm surprised: this is the first database which is able to create rows out of nothing. Violation of the conversation of energy data, eh? ;-)

MySQL Kundenkonferenz aka Sun Roadshow 2008

Am 21. Oktober 2008 war ich auf der MySQL Kundenkonferenz 2008 in München.

Es ist schon erstaunlich wie man aus einer anscheinend guten Konferenz (Aussage mehrerer Teilnehmer über die vorherige Veranstaltung) eine reine Werbeveranstaltung machen kann. Gleich zu Beginn gab es eine lange Warteschlange im Foyer des Hilton Hotels, die Damen am Empfang waren mit den über 200 Teilnehmern anscheinend etwas überfordert. Kommt halt nicht jeden Tag vor das alle Teilnehmer kurz vor Konferenzbeginn ankommen. Das Frühstück bzw. das Essen überhaupt war gut, aber für jemanden der keinen Kaffee trinkt blieb dann nur Wasser oder ein paar Sorten Tee zum selbst zubereiten übrig.

Etwas verspätet begann die Veranstaltung mit der Eröffnung durch Kaj Arnö sowie einem Vortrag von Robin Schumacher über die nächsten Schritte bei MySQL. Version 5.1 soll demnach noch dieses Jahr, Version 6 dann nächstes Jahr erscheinen. Zum häufiger nachgefragten Thema "Storage Engines" wurden den ganzen Tag über nicht viele Aussagen getroffen.

Die Fachvorträge waren meines Erachtens ihren Namen nicht wert. Der Memcached Vortrag glänzte mit einigen Folien die die Struktur solch eines Setups beschreiben. Effektiv etwas neues oder auch mal einen Blick ins Detail gab es jedoch nicht, auch wurde viel Wert auf MySQL gelegt und der Memcached mehr oder weniger nebenbei abgehandelt. Der Vortrag über den MySQL Proxy blieb ebenfalls weit hinter den Erwartungen zurück: es gab oberflächliche Informationen, wie und wo man den Proxy einsetzen könnte. Dazu wurden Vorzüge wie z.B. Sharding beschrieben. Im gesamten Vortrag habe ich jedoch Hinweise auf die möglichen Nachteile vermisst die bei solch einem Setup auftreten können - erst Recht wenn der Proxy transparent zwischen Kundenanwendungen und Datenbanken geschaltet wird.

Der Vortrag über den Stand der MySQL-Integration in Sun beschreibt im wesentlichen was zu erwarten war: alles läuft nach Plan.

Am Nachmittag gab es dann das unerwartete Highlight des Tages: Miriam Tuerk hält einen spannenden deutsch/englisch-gemischten Vortrag über Infobright. Die Technologie dahinter ist im wesentlichen eine Storage-Engine welche für Data Warehouse Anwendungen optimiert ist. Diverse Metadaten werden gleich beim Schreiben der Daten mitgespeichert und im besten Fall können Anfragen aus diesen Metadaten beantwortet werden. Laut Aussage von David Lutz (Infobright) ist das Konzept auch gut zur Auswertung großer Mengen an Logdateien geeignet, also werde ich dem ganzen mal einen Versuch gönnen. Erwähnenswert ist außerdem dass das für mich die erste sinnvolle Anwendung der austauschbaren Storage-Engines in MySQL darstellt.

Der "MySQL Performance Tuning" Vortrag fiel dann wieder zurück auf das Niveau des gesamten Tages: einige wenig aussagekräftige Folien und der Informationsgehalt des Vortrags war an sich Null. Selbst die Vorführung des "Enterprise Monitor" Tools wollte nicht recht gelingen.

Die Fragestunde zum Schluß zeigte viele interessante und tiefgreifend technische Fragen die offensichtlich während der Konferenz keinen Platz gefunden haben. Das verleitet mich zu der Annahme das diverse Teilnehmer ebenfalls mit einer anderen Erwartungshaltung nach München gekommen sind. Robin Schumacher war hierbei in seinem Element und konnte/durfte die meisten Fragen beantworten.

Das sonst übliche "Netzwerken" nach dem Ende der Konferenz viel erstaunlich kurz aus. Innerhalb weniger Minuten waren die meisten Teilnehmer verschwunden - was wiederum Platz für Fragen bei den MySQL Leuten ergab. Dabei zeigte sich dann dass das niedrige Niveau der Konferenz keineswegs an den Vortragenden selbst lag: auf alle technischen Fragen gab es eine Antwort.

Die Folien zur Konferenz sollten spätestens zwei Wochen später auf der Webseite verfügbar sein. Sehr lange zwei Wochen später lag dann heute eine E-Mail in meinem Postfach: [Link zu den Folien]. Wenn ich mir andere Veranstaltungen - auch und gerade im Open Source Bereich - anschaue dann sind dort die Folien teilweise am gleichen Tag verfügbar.

Bleibt zu hoffen das die nächste Userkonferenz nicht wieder zur Produktshow verkommt.

Performance issues

Last year, tweakers.net did some performance tests with MySQL and PostgreSQL and they found out that MySQL did not scale very well with many concurrent connections.


Now Kris Kennaway did some tests on his own and posted the results to the FreeBSD performance list. The resulting graphs look very similar.

Primary key in Mysql doubled

Got a nice problem: a table, which has the following primary key: id, id.

You can use or dump this table without problems ... but you cannot reinsert the dump into the same (4.1) or a newer (5.0) mysql version.

This is the table dump, created with "SHOW CREATE TABLE tablename":

----- cut -----
CREATE TABLE tablename (
id int(11) NOT NULL auto_increment,
title_en text,
...
PRIMARY KEY (id,id)
) TYPE=MyISAM DEFAULT CHARSET=latin1;
----- cut -----

Now i try to reinsert this table into another database:

----- cut -----
mysql> CREATE TABLE tablename (
-> id int(11) NOT NULL auto_increment,
-> title_en text,
...
-> PRIMARY KEY (id,id)
-> ) TYPE=MyISAM DEFAULT CHARSET=latin1;
ERROR 1060 (42S21): Duplicate column name 'id'
----- cut -----

What the ...


Should i repeat myself?

The real difference between MySQL and PostgreSQL

Just at FOSDEM, i was talking to a visitor and Susanne was talking to Lenz Grimmer from MySQL, who just visited our booth. The visitor i was talking to asked me, what the difference between both databases is, i pointed behind and told him: She (pointing to Susanne) is from PostgreSQL, he (pointing to Lenz) is from MySQL. Just ask for yourself.


The visitor looked right, looked left, back right and told me with a smile: "Yes, i can see the difference" ;-)

some tests from tweakers.net

tweakers.net has tested again the performance of PostgreSQL 8.2-dev and Mysql 4.1.20 and Mysql 5.0.20a. Results are nice and shown here.

Best thing: the collapses for requests per seconds if Mysql has a concurrency greater than 7. Oh, and by the way, they don't state the table type for Mysql so we don't know, if it is the fast and forgetfully MyIsam or the better but slower InnoDB type.

Mysql and real trigger support

I just answered a question in the usenet about triggers in Mysql and discovered something very scary:

You can have only one trigger action time and event at a time for a table. So for example you can only have one "BEFORE INSERT" trigger.


I only can repeat my earlier question: how can anyone get real work done with this *censored*?

Good article about comparisation of PostgreSQL and MySQL

devx.com has a fair comparisation about the two databases engines, not looking at the speed but at more important points like features, ACID, transactions or commercial and 24/7/365 support. In other words, all the things you want, if you decide to use a database in a production environment.

The article can be found at:

http://www.devx.com/dbzone/Article/20743/0/page/1