Linking Affects the Speed of MySQL

Most of the following tests are done on Linux with the MySQL benchmarks, but they should
give some indication for other operating systems and workloads.
You get the fastest executable when you link with -static.
On Linux, you will get the fastest code when compiling with pgcc and -O6. To compile
`sql_yacc.cc' with these options, you need about 200M memory because gcc/pgcc needs
a lot of memory to make all functions inline. You should also set CXX=gcc when con guring
MySQL to avoid inclusion of the libstdc++ library (it is not needed). Note that with some
versions of pgcc, the resulting code will only run on true Pentium processors, even if you
use the compiler option that you want the resulting code to be working on all x586 type
processors (like AMD).

By just using a better compiler and/or better compiler options you can get a 10-30 % speed
increase in your application. This is particularly important if you compile the SQL server
yourself !
We have tested both the Cygnus CodeFusion and Fujitsu compilers, but when we tested
them, neither was su ciently bug free to allow MySQL to be compiled with optimizations
on.
When you compile MySQL you should only include support for the character sets that you
are going to use. (Option --with-charset=xxx).


1If you use pgcc and compile everything with -O6, the mysqld server is 1% faster than
with gcc 2.95.2.
2 If you link dynamically (without -static), the result is 13% slower on Linux. Note
that you still can use a dynamic linked MySQL library. It is only the server that is
critical for performance.
3 If you connect using TCP/IP rather than Unix sockets, the result is 7.5% slower on
the same computer. (If you are connection to localhost, MySQL will, by default, use
sockets).
4 If you compile with --with-debug=full, then you will loose 20 % for most queries,
but some queries may take substantially longer (The MySQL benchmarks ran 35 %
slower) If you use --with-debug, then you will only loose 15 %.
5 On a Sun SPARCstation 20, SunPro C++ 4.2 is 5 % faster than gcc 2.95.2.
6 Compiling with gcc 2.95.2 for ultrasparc with the option -mcpu=v8 -Wa,-xarch=v8plusa
gives 4 % more performance.
7 On Solaris 2.5.1, MIT-pthreads is 8-12% slower than Solaris native threads on a single
processor. With more load/CPUs the di erence should get bigger.
8 Running with --log-bin makes [MySQL 1 % slower.
9 Compiling without frame pointers -fomit-frame-pointer with gcc makes MySQL 1
% faster.
The MySQL-Linux distribution provided by MySQL AB used to be compiled with pgcc,
but we had to go back to regular gcc because of a bug in pgcc that would generate the
code that does not run on AMD.
Related Posts:
  • Maximum Performance from MySQL Optimization is a complicated task because it ultimately requires understanding of the whole system. While it may be possible to do some local optimizations with small knowledge of your system/application, the more optimal y… Read More
  • What Is a Relational Database? The basic concepts of a relational database are fairly easy to understand. A relational database is a collection of related information that has been organized into structures known as tables. Each table contains rows th… Read More
  • MySQL Subqueries? You can use the result of a query like you use a list of values with the IN operator to filter a query based on the result of another query. The subquery appears in parentheses after the IN keyword. The following query f… Read More
  • MySQL Triggers To create a new trigger, use the CREATE TRIGGER statement. You must give the trigger a unique name and then provide the timing, action, and table that will cause the trigger to fire. For example, to create a trigger that… Read More
  • Combined Queries-UNION Mosy SQL queries contain just one SELECT statement that can return data from one table, or several tables using a join. The technique of combining two or more independent queries into a single data set is usually known a… Read More
  • SQL inherently SQL, or Structured Query Language, is not really a language. It does not follow all the rules of the typical computer programming language. There are no constructs in SQL to allow decision branches. You can't go to a sp… Read More
  • Data Control Language (DCL) statements ? Data Control Language (DCL) statements  Allow you to change the permissions on database structures. There are two DCL statements: GRANT  Allows you to give another user access to your database st… Read More
  • Web-Based MySQL Administration Web-Based MySQL Administration At http://phpwizard.net/phpMyAdmin you will find a PHP Web application that can help you manage MySQL. It enables you to manage a MySQL database using a browser and makes administrative work… Read More
  • Data Definition Language (DDL) statements? Data Definition Language (DDL) statements  Allow you to define the data structures, such as tables, that make up a database. There are five basic types of DDL statements: CREATE  Allows you to cr… Read More
  • MySQL Server Performance To make things  easier for administrators. Minimal memory, relatively infrequent MySQL usage: my-small.cnf Minimal memory combined with reliance on MySQL, or larger memory for a multipurpose system: my-medium.… Read More
  • Why NoSQL? Application requirements have fundamentally changed, and traditional RDBMS technology has failed to keep pace. As a result, the use of NoSQL technology is rising rapidly. Massive change is underway, disrupting the databas… Read More
  • what is Triggers? A trigger is a stored database object that contains a series of SQL commands, set to activate automatically when certain events take place. Each trigger is associated with a table. You can create a trigger that will fire… Read More
  • What Is SQL? The Structured Query Language (SQL) is the most common way to retrieve and manage database information. An SQL query consists of a series of keywords that define the data set you want to fetch from the database. SQL uses… Read More
  • Data Manipulation Language (DML) statements ? Data Manipulation Language (DML) statements  Allow you to modify the contents of tables. There are three DML statements: INSERT  Allows you to add rows to a table. UPDATE  Allows yo… Read More
  • Conditional Functions mysql The IF() Function The IF() function provides a way to return a value based on a condition within a query. The first argument is a condition that is evaluated for each row of the query. The value in the second is return… Read More