MySQL Reference Manual for version 3.22.14b-gamma.


19 How MySQL compares to other databases

19.1 How MySQL compares to mSQL

This section has been written by the MySQL developers, so it should be read with that in mind. But there are NO factual errors that we know of.

For a list of all supported limits, functions and types, see the crash-me web page.

Performance
For a true comparison of speed, consult the growing MySQL benchmark suite. See section 11 The MySQL benchmark suite. Because there is no thread creation overhead, a small parser, few features and simple security, mSQL should be quicker at: Since these operations are so simple, it is hard to be better at them when you have a higher startup overhead. After the connection is established, MySQL should perform much better. On the other hand, MySQL is much faster than mSQL (and most other SQL implementions) on the following:
SQL Features
Disk space efficiency
That is, how small can you make your tables? MySQL has very precise types, so you can create tables that take very little space. An example of a useful MySQL datatype is the MEDIUMINT that is 3 bytes long. If you have 100,000,000 records, saving even one byte per record is very important. mSQL2 has a more limited set of column types, so it is more difficult to get small tables.
Stability
This is harder to judge objectively. For a discussion of MySQL stability, see section 1.5 How stable is MySQL?. We have no experience with mSQL stability, so we cannot say anything about that.
Price
Another important issue is the license. MySQL has a more flexible license than mSQL, and is also less expensive than mSQL. Whichever product you choose to use, remember to at least consider paying for a license or email support. (You are required to get a license if you include MySQL with a product that you sell, of course.)
Perl interfaces
MySQL has basically the same interfaces to Perl as mSQL with some added features.
JDBC (Java)
MySQL currently has 4 JDBC drivers: The recommended drivers are the twz or mm driver. Both are reported to work excellently. We know that mSQL has a JDBC driver, but we have too little experience with it to compare.
Rate of development
MySQL has a very small team of developers, but we are quite used to coding C and C++ very rapidly. Since threads, functions, GROUP BY and so on are still not implemented in mSQL, it has a lot of catching up to do. To get some perspective on this, you can view the mSQL `HISTORY' file for the last year and compare it with the News section of the MySQL Reference Manual (see section D MySQL change history). It should be pretty obvious which one has developed most rapidly.
Utility programs
Both mSQL and MySQL have many interesting third-party tools. Since it is very easy to port upward (from mSQL to MySQL), almost all the interesting applications that are available for mSQL are also available for MySQL. MySQL comes with a simple msql2mysql program that fixes differences in spelling between mSQL and MySQL for the most-used C API functions. For example, it changes instances of msqlConnect() to mysql_connect(). Converting a client program from mSQL to MySQL usually takes a couple of minutes.

19.1.1 How to convert mSQL tools for MySQL

According to our experience, it would just take a few hours to convert tools such as msql-tcl and msqljava that use the mSQL C API so that they work with the MySQL C API.

The conversion procedure is:

  1. Run the shell script msql2mysql on the source. This requires the replace program, which is distributed with MySQL.
  2. Compile.
  3. Fix all compiler errors.

Differences between the mSQL C API and the MySQL C API are:

19.1.2 How mSQL and MySQL client/server communications protocols differ

There are enough differences that it is impossible (or at least not easy) to support both.

The most significant ways in which the MySQL protocol differs from the mSQL protocol are listed below:

19.1.3 How mSQL 2.0 SQL syntax differs from MySQL

Column types

MySQL
Has the following additional types (among others; see section 7.6 CREATE TABLE syntax):
MySQL also supports the following additional type attributes:
mSQL2
mSQL column types correspond to the MySQL types shown below:
mSQL type Corresponding MySQL type
CHAR(len) CHAR(len)
TEXT(len) TEXT(len). len is the maximal length. And LIKE works.
INT INT. With many more options!
REAL REAL. Or FLOAT. Both 4- and 8-byte versions are available.
UINT INT UNSIGNED
DATE DATE. Uses ANSI SQL format rather than mSQL's own.
TIME TIME
MONEY DECIMAL(12,2). A fixed-point value with two decimals.

Index creation

MySQL
Indexes may be specified at table creation time with the CREATE TABLE statement.
mSQL
Indexes must be created after the table has been created, with separate CREATE INDEX statements.

To insert a unique identifier into a table

MySQL
Use AUTO_INCREMENT as a column type specifier. See section 18.4.49 How can I get the unique ID for the last inserted row?.
mSQL
Create a SEQUENCE on a table and select the _seq column.

To obtain a unique identifier for a row

MySQL
Add a PRIMARY KEY or UNIQUE key to the table.
mSQL
Use the _rowid column. Observe that _rowid may change over time depending on many factors.

To get the time a column was last modified

MySQL
Add a TIMESTAMP column to the table. This column is automatically set to the current time for INSERT or UPDATE statements if you don't give the column a value or if you give it a NULL value.
mSQL
Use the _timestamp column.

NULL value comparisons

MySQL
MySQL follows ANSI SQL and a comparison with NULL is always NULL.
mSQL
In mSQL, NULL = NULL is TRUE. You must change =NULL to IS NULL and <>NULL to IS NOT NULL when porting old code from mSQL to MySQL.

String comparisons

MySQL
Normally, string comparisons are performed in case-independent fashion with the sort order determined by the current character set (ISO-8859-1 Latin1 by default). If you don't like this, declare your columns with the BINARY attribute, which causes comparisons to be done according to the ASCII order used on the MySQL server host.
mSQL
All string comparisons are performed in case-sensitive fashion with sorting in ASCII order.

Case-insensitive searching

MySQL
LIKE is a case-insensitive or case-sensitive operator, depending on the columns involved. If possible, MySQL uses indexes if the LIKE argument doesn't start with a wildcard character.
mSQL
Use CLIKE.

Handling of trailing spaces

MySQL
Strips all spaces at the end of CHAR and VARCHAR columns. Use a TEXT column if this behavior is not desired.
mSQL
Retains trailing space.

WHERE clauses

MySQL
MySQL correctly prioritizes everything (AND is evaluated before OR). To get mSQL behavior in MySQL, use parentheses (as shown below).
mSQL
Evaluates everything from left to right. This means that some logical calculations with more than three arguments cannot be expressed in any way. It also means you must change some queries when you upgrade to MySQL. You do this easily by adding parentheses. Suppose you have the following mSQL query:
mysql> SELECT * FROM table WHERE a=1 AND b=2 OR a=3 AND b=4;
To make MySQL evaluate this the way that mSQL would, you must add parentheses:
mysql> SELECT * FROM table WHERE (a=1 AND (b=2 OR (a=3 AND (b=4))));

Access control

MySQL
Has tables to store grant (permission) options per user, host and database. See section 6.4 How the privilege system works.
mSQL
Has a file `mSQL.acl' in which you can grant read/write privileges for users.

19.2 How MySQL compares to PostgreSQL

PostgreSQL has some more advanced features like user-defined types, triggers, rules and transactions. But it lacks many of the standard types and functions from ANSI SQL and ODBC. See the crash-me web page for a complete list of which limits, types and functions are supported or unsupported.

Normally, PostgreSQL is much slower than MySQL. See section 11 The MySQL benchmark suite. This is due largely to their transactions system. If you really need transactions and can afford to pay the speed penalty, you should take a look at PostgreSQL.

19.3 Changes in release 3.22.x (Beta version)

The 3.22 version has faster and safer connect code and a lot of new nice enhancements. The reason for not including these changes in the 3.21 version is mainly that we are trying to avoid big changes to 3.21 to keep it as stable as possible. As there aren't really any MAJOR changes, upgrading to 3.22 should be very easy and painless.

3.22 should also be used with the new DBD-mysql (1.2000) driver that can use the new connect protocol!

Note that we tend to update the manual at the same time we implement new things to MySQL. If you find a version listed below that you can't find on the MySQL download page, this means that the version has not yet been released!

Note that we tend to update the manual at the same time we implement new things to MySQL. If you find a version listed below that you can't find on the MySQL download page, this means that the version has not yet been released!

19.3.1 Changes in release 3.22.14

19.3.2 Changes in release 3.22.13

19.3.3 Changes in release 3.22.12

19.3.4 Changes in release 3.22.11

19.3.5 Changes in release 3.22.10

19.3.6 Changes in release 3.22.9

19.3.7 Changes in release 3.22.8

19.3.8 Changes in release 3.22.7

19.3.9 Changes in release 3.22.6

19.3.10 Changes in release 3.22.5

19.3.11 Changes in release 3.22.4

19.3.12 Changes in release 3.22.3

19.3.13 Changes in release 3.22.2

19.3.14 Changes in release 3.22.1

19.3.15 Changes in release 3.22.0

19.4 Changes in release 3.21.x

19.4.1 Changes in release 3.21.33

19.4.2 Changes in release 3.21.32

19.4.3 Changes in release 3.21.31

19.4.4 Changes in release 3.21.30

19.4.5 Changes in release 3.21.29

19.4.6 Changes in release 3.21.28

19.4.7 Changes in release 3.21.27

19.4.8 Changes in release 3.21.26

19.4.9 Changes in release 3.21.25

19.4.10 Changes in release 3.21.24

19.4.11 Changes in release 3.21.23

19.4.12 Changes in release 3.21.22

19.4.13 Changes in release 3.21.21a

19.4.14 Changes in release 3.21.21

19.4.15 Changes in release 3.21.20

19.4.16 Changes in release 3.21.19

19.4.17 Changes in release 3.21.18

19.4.18 Changes in release 3.21.17

19.4.19 Changes in release 3.21.16

19.4.20 Changes in release 3.21.15

19.4.21 Changes in release 3.21.14b

19.4.22 Changes in release 3.21.14a

19.4.23 Changes in release 3.21.13

19.4.24 Changes in release 3.21.12

19.4.25 Changes in release 3.21.11

19.4.26 Changes in release 3.21.10

19.4.27 Changes in release 3.21.9

19.4.28 Changes in release 3.21.8

19.4.29 Changes in release 3.21.7

19.4.30 Changes in release 3.21.6

19.4.31 Changes in release 3.21.5

19.4.32 Changes in release 3.21.4

19.4.33 Changes in release 3.21.3

19.4.34 Changes in release 3.21.2

19.4.35 Changes in release 3.21.0

19.5 Changes in release 3.20.x

Changes from 3.20.18 to 3.20.32b are not documented here since the 3.21 release branched here. And the relevant changes are also documented as changes to the 3.21 version.

19.5.1 Changes in release 3.20.18

19.5.2 Changes in release 3.20.17

19.5.3 Changes in release 3.20.16

19.5.4 Changes in release 3.20.15

19.5.5 Changes in release 3.20.14

19.5.6 Changes in release 3.20.13

19.5.7 Changes in release 3.20.11

19.5.8 Changes in release 3.20.10

19.5.9 Changes in release 3.20.9

19.5.10 Changes in release 3.20.8

19.5.11 Changes in release 3.20.7

19.5.12 Changes in release 3.20.6

19.5.13 Changes in release 3.20.3

19.5.14 Changes in release 3.20.0

19.6 Changes in release 3.19.x

19.6.1 Changes in release 3.19.5

19.6.2 Changes in release 3.19.4

19.6.3 Changes in release 3.19.3

19.7 Things that must done in the real near future

19.8 Things that have to be done sometime

Time is given according to amount of work, not real time. TcX's main business is the use of MySQL not the development of it. But since TcX is a very flexible company, we have put a lot of resources into the development of MySQL.

19.9 Some things we don't have any plans to do

19.10 Debugging MySQL

If you have some very specific problem, you can always try to debug MySQL. To do this you must configure MySQL with the option --with-debug. You can check whether or not MySQL was compiled with debugging by doing: mysqld --help. If the --debug flag is listed with the options then you have debugging enabled. mysqladmin ver also lists the mysqld version as mysql ... -debug in this case.

If you are using gcc or egcs, the recommended configure line is:

CC=gcc CFLAGS="-O6" CXX=gcc CXXFLAGS="-O6 -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --with-debug

This will avoid problems with the libstdc++ library and with C++ exceptions.

If you can cause the mysqld server to crash quickly, you can try to create a trace file of this:

Start the mysqld server with a trace log in `/tmp/mysql.trace'. The log file will get very BIG.

mysqld --debug --log

or you can start it with

mysqld --debug=d,info,error,query,general,where:O,/tmp/mysql.trace

which only prints information with the most interesting tags.

When you configure MySQL for debugging you automatically enable a lot of extra safety check functions that monitor the health of mysqld. If they find something "unexpected," an entry will be written to stderr, which safe_mysqld directs to the error log! This also means that if you are having some unexpected problems with MySQL and are using a source distribution, the first thing you should do is to configure MySQL for debugging! (The second thing, of course, is to send mail to mysql@tcx.se and ask for help. Please use the mysqlbug script for all bug reports or questions regarding the MySQL version you are using!

On most system you can also start mysqld from gdb to get more information if mysqld crashes.

shell> gdb /usr/local/libexec/mysqld
gdb> run
...
back   # Do this when mysqld crashes
info locals
up
info locals
up
...
(until you get some information about local variables)

quit

On Linux you must use run --one-thread if you want to be able to debug mysqld threads. In this case you can only have one thread active at a time.

Include the above output in a mail generated with mysqlbug and mail this to mysql@tcx.se.

If mysqld hangs you can try to use some system tools like strace or /usr/proc/bin/pstack to examine where mysqld has hanged.

If mysqld starts to eat up CPU or memory or if it 'hangs', you can use mysqladmin processlist status to find out if someone is executing some query that takes a long time. It may be a good idea to run mysqladmin -i10 processlist status in some window if you are experiencing performance problems.

If mysqld dies or hangs, you should start mysqld with --log. When mysqld dies again, you can check in the log file for the query that killed mysqld. Note that before starting mysqld with --log you should check all your tables with isamchk. See section 13 Using isamchk for table maintenance and crash recovery.

If you are using a log file, mysqld --log, you should check the 'hostname' log files, that you can find in the database directory, for any queries that could cause a problem. Try the command EXPLAIN on all SELECT statements that takes a long time to ensure that mysqld are using indexes properly. See section 7.21 EXPLAIN syntax (Get information about a SELECT). You should also test complicated queries that didn't complete within the mysql command line tool.

If you find the text mysqld restarted in the error log file (normally named `hostname.err') you have probably found a query that causes mysqld to fail. If this happens you should check all your tables with isamchk (see section 13 Using isamchk for table maintenance and crash recovery), and test the queries in the MySQL log files if someone doesn't work. If you find such a query, try first upgrading to the newest MySQL version. If this doesn't help and you can't find anything in the mysql mail archive, you should report the bug to online MySQL documentation page.

If you get corrupted tables or if mysqld always fails after some update commands, you can test if this bug is reproducible by doing the following:

The command mysqladmin debug will dump some information about locks in use, used memory and query usage to the mysql log file. This may help solve some problems. This command also provides some usefull information even if you haven't compiled MySQL for debugging!

If the problem is that some tables are getting slower and slower you should try to repair the tables with isamchk to optimize the table layout. You should also check the slow queries with EXPLAIN. See section 13 Using isamchk for table maintenance and crash recovery.

You should also read the OS-specific section in this manual for problems that may be unique to your environment. See section 4.11 System-specific notes

19.11 Comments about RTS threads

I have tried to use the RTS thread packages with MySQL but stumbled on the following problems:

They use old version of a lot of POSIX calls and it is very tedious to make wrappers for all functions. I am inclined to think that it would be easier to change the thread libraries to the newest POSIX specification.

Some wrappers are already written. See `mysys/my_pthread.c' for more info.

At least the following should be changed:

pthread_get_specific should use one argument. sigwait should take two arguments. A lot of functions (at least pthread_cond_wait, pthread_cond_timedwait) should return the error code on error. Now they return -1 and set errno.

Another problem is that user-level threads use the ALRM signal and this aborts a lot of functions (read, write, open...). MySQL should do a retry on interrupt on all of these but it is not that easy to verify it.

The biggest unsolved problem is the following:

To get thread-level alarms I changed `mysys/thr_alarm.c' to wait between alarms with pthread_cond_timedwait(), but this aborts with error EINTR. I tried to debug the thread library as to why this happens, but couldn't find any easy solution.

If someone wants to try MySQL with RTS threads I suggest the following:

19.12 Differences between different thread packages

MySQL is very dependent on the thread package used. So when choosing a good platform for MySQL, the thread package is very important.

There are at least three types of thread packages:

In some systems kernel threads are managed by integrating user level threads in the system libraries. In such cases, the thread switching can only be done by the thread library and the kernel isn't really "thread aware".


This document was generated on 3 January 1999 using the texi2html translator version 1.52 (extended by davida@detron.se).