Skip to content

Instantly share code, notes, and snippets.

@progress44
Last active August 4, 2016 20:04
Show Gist options
  • Save progress44/4acb3eaae803a737a699b423644cac3c to your computer and use it in GitHub Desktop.
Save progress44/4acb3eaae803a737a699b423644cac3c to your computer and use it in GitHub Desktop.
SELECT concat('alter table ',table_schema,'.',table_name,' DROP FOREIGN KEY ',constraint_name,';')
FROM information_schema.table_constraints
WHERE constraint_type='FOREIGN KEY'
AND table_schema='cm_demo_myIsam';
SHOW ENGINE INNODB STATUS;
-- You must also set innodb_log_file_size to 25% of innodb_buffer_pool_size or 2047M, which ever is smaller. To change the file ib_logfile0 and ib_logfile1, you must:
mysql -uroot -p -e"SET GLOBAL innodb_fast_shutdown = 0;"
service mysql stop
rm ib_logfile0 ib_logfile1
service mysql start
SELECT CONCAT(ROUND(KBS/POWER(1024,IF(pw<0,0,IF(pw>3,0,pw)))+0.49999),
SUBSTR(' KMG',IF(pw<0,0,IF(pw>3,0,pw))+1,1)) recommended_innodb_buffer_pool_size
FROM (SELECT SUM(index_length) KBS FROM information_schema.tables WHERE
engine='InnoDB') A,(SELECT 3 pw) B;
SELECT CONCAT(ROUND(KBS/POWER(1024,IF(pw<0,0,IF(pw>3,0,pw)))+0.49999),
SUBSTR(' KMG',IF(pw<0,0,IF(pw>3,0,pw))+1,1)) recommended_key_buffer_size
FROM (SELECT SUM(index_length) KBS FROM information_schema.tables
WHERE engine='MyISAM' AND table_schema NOT IN ('information_schema','mysql')) A,
(SELECT 3 pw) B;
innodb_read_io_threads=64
innodb_write_io_threads=64
innodb_io_capacity=20000 -- (set this to your device's IOPs) .. actually don't set too high
@progress44
Copy link
Author

Your innodb_buffer_pool_size should be set to the amount of InnoDB data and indexes you have. Run this query and it will tell you the Minimum recommended setting for mysql's current Innodb Data

If your InnoDB data far exceeds the installed RAM on the DB server, I recommend 75% of the installed RAM on the box. So, if you have a 16GB server, use 12G as the innodb_buffer_pool_size.

Options Description

  • innodb_buffer_pool_size=12G Default is 128M. 70-80% of memory for dedicated 64bit MySQL server. Example: 12G on 16GB box. The larger you set this value, the less disk I/O is needed to access data in tables.
  • innodb_change_buffering=all Update and delete operations are buffered in addition to insert
  • innodb_additional_mem_pool_size=20M Additional memory for InnoDB miscellaneous needs..
  • innodb_file_per_table Increase performance in optimize, backup, restore, compress and truncating a table
  • innodb_log_file_size= 2048M Set the log file size to about 25% of the buffer pool size.
  • innodb_log_buffer_size=16M Default is 8M. 16M is good for most cases unless you’re piping large blobs to InnoDB in this case increase it a bit. Larger the number less disk IO usage (suitable
    for large transaction DB)
  • innodb_flush_log_at_trx_commit=1 Set to 1 if database transaction is more important than performance. Set to 2 if performance is more important than transaction.
  • innodb_thread_concurrency=8 Default is 0. Usually 2 x no of core
  • innodb_flush_method=O_DIRECT This to avoid double buffering and reduce swap pressure, in most cases this setting improves performance
  • innodb_read_io_threads=16 If using MySQL 5.5 only. Default is 4. Better 4 x no of core
  • innodb_write_io_threads=16 If using MySQL 5.5 only. Default is 4. Better 4 x no of core
  • innodb_io_capacity=500 Default is 200. If SATA = 100. If SAS = 200. If RAID 5, 10 = 500
  • innodb_lock_wait_timeout=120 Default is 50 seconds. Increase the value for reliability or decrease for performance
  • innodb_data_file_path=ibdata1:50M;ibdata2:50M:autoextend A tablespace containing a fixed-size 50MB data file named ibdata1 and a 50MB auto-extending file named ibdata2 in the data directory.

Sizes are specified * using K, M, or G suffix letters to indicate units of KB, MB, or GB. Data files must be able to hold your data and indexes total size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment