3. Server Variables
The MySQL server maintains many system variables
that indicate how it is configured.
• Each system variable has its default value.
• We can dynamically change these settings using
SET command.
• SHOW VARIABLES
• Currently there are 291 variables defined in
MySQL 5.1.6
• SHOW VARIABLES LIKE 'have_query_cache';
• SHOW STATUS LIKE 'Table%';
4. Query Cache
• The have_query_cache server system variable
indicates whether the query cache is available.
• SHOW VARIABLES LIKE 'have_query_cache';
• It totally depends upon query_cache_type and
query_cache_size
• query_cache_type is of 0,1 and 2 (On DEMAND)
• You can set max query_cache_size (1MB) as
well as query_cache_min_res_unit (4KB)
• SHOW STATUS LIKE '%qcache%';
5. Locking Issues
• SHOW STATUS LIKE 'Table%';
To achieve a very high lock speed, MySQL uses table
locking (instead of page, row, or column locking)
for all storage engines except InnoDB and
NDBCLUSTER.
• Internal Locking
• External Locking
• Concurrent Inserts
6. Internal Locking
Performed within the MySQL server itself to manage
contention for table contents by multiple sessions.
MySQL grants table write locks as follows:
-If there are no locks on the table, put a write lock
on it.Otherwise, put the lock request in the write
lock queue.
MySQL grants table read locks as follows:
-If there are no write locks on the table, put a read
lock on it.Otherwise, put the lock request in the
read lock queue.
7. External Locking
• External locking is used in situations where a
single process such as the MySQL server cannot
be assumed to be the only process that requires
access to tables.
• If you run multiple servers that use the same
database directory, each server must have
external locking enabled.
• With external locking in effect, each process
that requires access to a table acquires a file
system lock for the table files before proceeding
to access the table.
8. External Locking
• External locking affects server performance
because the server must sometimes wait for
other processes before it can access tables.
• The easiest way to satisfy these conditions is to
always use --external-locking together with
• skip_external_locking = OFF
• SET delay-key-write=OFF
• SET query-cache-size=0.
9. Concurrent Inserts
• The MySQL storage engine supports
concurrent inserts to reduce contention
between readers and writers for a given table
• An INSERT statement can be executed to add
rows to the end of the table at the same time
that SELECT statements are reading rows
from the table.
• If there are multiple INSERT statements,
they are queued and performed in sequence,
concurrently with the SELECT statements.
10. Concurrent Inserts
- concurrent_insert = 0, 1, 2
0) If concurrent_insert is set to 0, concurrent
inserts are disabled.
1) By default, the variable is set to 1 and
concurrent inserts are handled.
2) If the variable is set to 2, concurrent inserts at
the end of the table are permitted even for
tables that have deleted rows(holes).
11. Connection Pooling
• By default, connection pooling is enabled in
ADO.NET, Unless you explicitly disable it.
• Only connections with the same configuration
can be pooled. ADO.NET keeps several pools at
the same time, one for each configuration.
• Connections are separated into pools by
connection string, and by Windows identity when
integrated security is used.
• A connection pool is created for each unique
connection string.
12. Connection Pooling
- Connections are added to the pool as needed, up to
the maximum pool size specified (100 is the
default).
- Connections are released back into the pool when
they are closed or disposed.
- If MinPoolSize is either not specified in the
connection string or is specified as 0, the
connections in the pool will be closed after a
period of inactivity.
- However, if the specified MinPoolSize is greater
than zero, the connection pool is not destroyed
until the AppDomain is unloaded and the process