10.3 How compiling and linking affects the speed of MySQL

Most of the following tests are done on Linux and with the MySQL benchmarks, but they should give some indication for other operating systems.

You get the fastest executable when you link with -static. Using Unix sockets rather than TCP/IP to connect to a database also gives better performance.

On Linux, you will get the fastest code when compiling with pgcc and -O6. To compile `sql_yacc.cc' with these options, you need 180M memory because gcc/pgcc needs a lot of memory to make all functions inline. You should also set CXX=gcc when configuring MySQL to avoid inclusion of the libstdc++ library.

  • If you use pgcc and compile everything with -O6, the mysqld server is 11% faster than with gcc.
  • If you link dynamically (without -static), the result is 13% slower.
  • If you connect using TCP/IP rather than Unix sockets, the result is 7.5% slower.
  • On a Sun SPARCstation 10, gcc 2.7.3 is 13% faster than Sun Pro C++ 4.2.
  • On Solaris 2.5.1, MIT-pthreads is 8-12% slower than Solaris native threads.

The MySQL-Linux distribution provided by TcX is compiled with pgcc and linked statically.