I would like if anybody could look into performance optimize this:
I have a Ubuntu 12.04 running on VMWare 5.1, with 32 GB RAM and 8 Cores (No problems regarding cpu scheduling as the VM is almost alone on the host) The hardware is IBM blade with 2xE5-2660 CPU's
Im running Mysql 5.5, and have a table looking like this:
ochrange | CREATE TABLE `ochrange` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`rangestart` int(8) NOT NULL,
`rangeend` int(8) NOT NULL,
`rangelength` int(11) NOT NULL DEFAULT '1',
`networkoperator` varchar(6) COLLATE latin1_danish_ci NOT NULL,
`serviceoperator` varchar(6) COLLATE latin1_danish_ci NOT NULL,
`numbertype` varchar(6) COLLATE latin1_danish_ci NOT NULL,
`lastupdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`lastupdateFile` varchar(255) COLLATE latin1_danish_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `rangestart_2` (`rangestart`,`rangeend`),
KEY `rangelength` (`rangelength`)
) ENGINE=MyISAM AUTO_INCREMENT=189138 DEFAULT CHARSET=latin1 COLLATE=latin1_danish_ci |
The table contains 187,500 rows.
Im running queries like this:
SELECT `networkoperator`,`numbertype`
FROM `och`.`ochrange`
WHERE '20972128'
BETWEEN `rangestart` AND `rangeend`
ORDER BY `rangelength` ASC LIMIT 1;
mysql> EXPLAIN SELECT `networkoperator`,`numbertype`
-> FROM `och`.`ochrange`
-> WHERE '20972128'
-> BETWEEN `rangestart` AND `rangeend`
-> ORDER BY `rangelength` ASC LIMIT 1;
+----+-------------+----------+-------+---------------+-------------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------+-------+---------------+-------------+---------+------+------+-------------+
| 1 | SIMPLE | ochrange | index | rangestart_2 | rangelength | 4 | NULL | 46 | Using where |
+----+-------------+----------+-------+---------------+-------------+---------+------+------+-------------+
1 row in set (0.00 sec)
There are no other queries in the slow log, and the number of other queries is minimal.
Im able to do 60 qps like this, before my CPU is maxed out, and the server has a load about 150, and I'm using 21000 Mhz on the VMWare host.
I have no IO wait (0.5%) and the memory usage seems fine.
The query cache is disabled as no select will be the same in a short period.
Anybody have any suggestions about how the get more qps ?
Here are my server variables:
Variable_name: auto_increment_increment
Value: 1
Variable_name: auto_increment_offset
Value: 1
Variable_name: autocommit
Value: ON
Variable_name: automatic_sp_privileges
Value: ON
Variable_name: back_log
Value: 50
Variable_name: basedir
Value: /usr
Variable_name: big_tables
Value: OFF
Variable_name: binlog_cache_size
Value: 32768
Variable_name: binlog_direct_non_transactional_updates
Value: OFF
Variable_name: binlog_format
Value: STATEMENT
Variable_name: binlog_stmt_cache_size
Value: 32768
Variable_name: bulk_insert_buffer_size
Value: 8388608
Variable_name: character_set_client
Value: utf8
Variable_name: character_set_connection
Value: utf8
Variable_name: character_set_database
Value: latin1
Variable_name: character_set_filesystem
Value: binary
Variable_name: character_set_results
Value: utf8
Variable_name: character_set_server
Value: latin1
Variable_name: character_set_system
Value: utf8
Variable_name: character_sets_dir
Value: /usr/share/mysql/charsets/
Variable_name: collation_connection
Value: utf8_general_ci
Variable_name: collation_database
Value: latin1_swedish_ci
Variable_name: collation_server
Value: latin1_swedish_ci
Variable_name: completion_type
Value: NO_CHAIN
Variable_name: concurrent_insert
Value: AUTO
Variable_name: connect_timeout
Value: 10
Variable_name: datadir
Value: /var/lib/mysql/
Variable_name: date_format
Value: %Y-%m-%d
Variable_name: datetime_format
Value: %Y-%m-%d %H:%i:%s
Variable_name: default_storage_engine
Value: InnoDB
Variable_name: default_week_format
Value: 0
Variable_name: delay_key_write
Value: ON
Variable_name: delayed_insert_limit
Value: 100
Variable_name: delayed_insert_timeout
Value: 300
Variable_name: delayed_queue_size
Value: 1000
Variable_name: div_precision_increment
Value: 4
Variable_name: engine_condition_pushdown
Value: ON
Variable_name: error_count
Value: 0
Variable_name: event_scheduler
Value: OFF
Variable_name: expire_logs_days
Value: 7
Variable_name: external_user
Value:
Variable_name: flush
Value: OFF
Variable_name: flush_time
Value: 0
Variable_name: foreign_key_checks
Value: ON
Variable_name: ft_boolean_syntax
Value: + -><()~*:""&|
Variable_name: ft_max_word_len
Value: 84
Variable_name: ft_min_word_len
Value: 4
Variable_name: ft_query_expansion_limit
Value: 20
Variable_name: ft_stopword_file
Value: (built-in)
Variable_name: general_log
Value: OFF
Variable_name: general_log_file
Value: /var/lib/mysql/db-nrlookup.log
Variable_name: group_concat_max_len
Value: 1024
Variable_name: have_compress
Value: YES
Variable_name: have_crypt
Value: YES
Variable_name: have_csv
Value: YES
Variable_name: have_dynamic_loading
Value: YES
Variable_name: have_geometry
Value: YES
Variable_name: have_innodb
Value: YES
Variable_name: have_ndbcluster
Value: NO
Variable_name: have_openssl
Value: DISABLED
Variable_name: have_partitioning
Value: YES
Variable_name: have_profiling
Value: YES
Variable_name: have_query_cache
Value: YES
Variable_name: have_rtree_keys
Value: YES
Variable_name: have_ssl
Value: DISABLED
Variable_name: have_symlink
Value: YES
Variable_name: hostname
Value: db-nrlookup
Variable_name: identity
Value: 0
Variable_name: ignore_builtin_innodb
Value: OFF
Variable_name: init_connect
Value:
Variable_name: init_file
Value:
Variable_name: init_slave
Value:
Variable_name: innodb_adaptive_flushing
Value: ON
Variable_name: innodb_adaptive_hash_index
Value: ON
Variable_name: innodb_additional_mem_pool_size
Value: 8388608
Variable_name: innodb_autoextend_increment
Value: 8
Variable_name: innodb_autoinc_lock_mode
Value: 1
Variable_name: innodb_buffer_pool_instances
Value: 1
Variable_name: innodb_buffer_pool_size
Value: 134217728
Variable_name: innodb_change_buffering
Value: all
Variable_name: innodb_checksums
Value: ON
Variable_name: innodb_commit_concurrency
Value: 0
Variable_name: innodb_concurrency_tickets
Value: 500
Variable_name: innodb_data_file_path
Value: ibdata1:10M:autoextend
Variable_name: innodb_data_home_dir
Value:
Variable_name: innodb_doublewrite
Value: ON
Variable_name: innodb_fast_shutdown
Value: 1
Variable_name: innodb_file_format
Value: Antelope
Variable_name: innodb_file_format_check
Value: ON
Variable_name: innodb_file_format_max
Value: Antelope
Variable_name: innodb_file_per_table
Value: OFF
Variable_name: innodb_flush_log_at_trx_commit
Value: 1
Variable_name: innodb_flush_method
Value:
Variable_name: innodb_force_load_corrupted
Value: OFF
Variable_name: innodb_force_recovery
Value: 0
Variable_name: innodb_io_capacity
Value: 200
Variable_name: innodb_large_prefix
Value: OFF
Variable_name: innodb_lock_wait_timeout
Value: 50
Variable_name: innodb_locks_unsafe_for_binlog
Value: OFF
Variable_name: innodb_log_buffer_size
Value: 8388608
Variable_name: innodb_log_file_size
Value: 5242880
Variable_name: innodb_log_files_in_group
Value: 2
Variable_name: innodb_log_group_home_dir
Value: ./
Variable_name: innodb_max_dirty_pages_pct
Value: 75
Variable_name: innodb_max_purge_lag
Value: 0
Variable_name: innodb_mirrored_log_groups
Value: 1
Variable_name: innodb_old_blocks_pct
Value: 37
Variable_name: innodb_old_blocks_time
Value: 0
Variable_name: innodb_open_files
Value: 300
Variable_name: innodb_print_all_deadlocks
Value: OFF
Variable_name: innodb_purge_batch_size
Value: 20
Variable_name: innodb_purge_threads
Value: 0
Variable_name: innodb_random_read_ahead
Value: OFF
Variable_name: innodb_read_ahead_threshold
Value: 56
Variable_name: innodb_read_io_threads
Value: 4
Variable_name: innodb_replication_delay
Value: 0
Variable_name: innodb_rollback_on_timeout
Value: OFF
Variable_name: innodb_rollback_segments
Value: 128
Variable_name: innodb_spin_wait_delay
Value: 6
Variable_name: innodb_stats_method
Value: nulls_equal
Variable_name: innodb_stats_on_metadata
Value: ON
Variable_name: innodb_stats_sample_pages
Value: 8
Variable_name: innodb_strict_mode
Value: OFF
Variable_name: innodb_support_xa
Value: ON
Variable_name: innodb_sync_spin_loops
Value: 30
Variable_name: innodb_table_locks
Value: ON
Variable_name: innodb_thread_concurrency
Value: 0
Variable_name: innodb_thread_sleep_delay
Value: 10000
Variable_name: innodb_use_native_aio
Value: OFF
Variable_name: innodb_use_sys_malloc
Value: ON
Variable_name: innodb_version
Value: 5.5.34
Variable_name: innodb_write_io_threads
Value: 4
Variable_name: insert_id
Value: 0
Variable_name: interactive_timeout
Value: 28800
Variable_name: join_buffer_size
Value: 131072
Variable_name: keep_files_on_create
Value: OFF
Variable_name: key_buffer_size
Value: 8589934592
Variable_name: key_cache_age_threshold
Value: 300
Variable_name: key_cache_block_size
Value: 1024
Variable_name: key_cache_division_limit
Value: 100
Variable_name: large_files_support
Value: ON
Variable_name: large_page_size
Value: 0
Variable_name: large_pages
Value: OFF
Variable_name: last_insert_id
Value: 0
Variable_name: lc_messages
Value: en_US
Variable_name: lc_messages_dir
Value: /usr/share/mysql/
Variable_name: lc_time_names
Value: en_US
Variable_name: license
Value: GPL
Variable_name: local_infile
Value: ON
Variable_name: lock_wait_timeout
Value: 31536000
Variable_name: locked_in_memory
Value: OFF
Variable_name: log
Value: OFF
Variable_name: log_bin
Value: ON
Variable_name: log_bin_trust_function_creators
Value: OFF
Variable_name: log_error
Value: /var/log/mysql/error.log
Variable_name: log_output
Value: FILE
Variable_name: log_queries_not_using_indexes
Value: OFF
Variable_name: log_slave_updates
Value: OFF
Variable_name: log_slow_queries
Value: ON
Variable_name: log_warnings
Value: 1
Variable_name: long_query_time
Value: 10.000000
Variable_name: low_priority_updates
Value: OFF
Variable_name: lower_case_file_system
Value: OFF
Variable_name: lower_case_table_names
Value: 0
Variable_name: max_allowed_packet
Value: 134217728
Variable_name: max_binlog_cache_size
Value: 18446744073709547520
Variable_name: max_binlog_size
Value: 209715200
Variable_name: max_binlog_stmt_cache_size
Value: 18446744073709547520
Variable_name: max_connect_errors
Value: 10
Variable_name: max_connections
Value: 8000
Variable_name: max_delayed_threads
Value: 20
Variable_name: max_error_count
Value: 64
Variable_name: max_heap_table_size
Value: 16777216
Variable_name: max_insert_delayed_threads
Value: 20
Variable_name: max_join_size
Value: 18446744073709551615
Variable_name: max_length_for_sort_data
Value: 1024
Variable_name: max_long_data_size
Value: 134217728
Variable_name: max_prepared_stmt_count
Value: 16382
Variable_name: max_relay_log_size
Value: 0
Variable_name: max_seeks_for_key
Value: 18446744073709551615
Variable_name: max_sort_length
Value: 1024
Variable_name: max_sp_recursion_depth
Value: 0
Variable_name: max_tmp_tables
Value: 32
Variable_name: max_user_connections
Value: 0
Variable_name: max_write_lock_count
Value: 18446744073709551615
Variable_name: metadata_locks_cache_size
Value: 1024
Variable_name: min_examined_row_limit
Value: 0
Variable_name: multi_range_count
Value: 256
Variable_name: myisam_data_pointer_size
Value: 6
Variable_name: myisam_max_sort_file_size
Value: 9223372036853727232
Variable_name: myisam_mmap_size
Value: 18446744073709551615
Variable_name: myisam_recover_options
Value: BACKUP
Variable_name: myisam_repair_threads
Value: 1
Variable_name: myisam_sort_buffer_size
Value: 8388608
Variable_name: myisam_stats_method
Value: nulls_unequal
Variable_name: myisam_use_mmap
Value: OFF
Variable_name: net_buffer_length
Value: 16384
Variable_name: net_read_timeout
Value: 30
Variable_name: net_retry_count
Value: 10
Variable_name: net_write_timeout
Value: 60
Variable_name: new
Value: OFF
Variable_name: old
Value: OFF
Variable_name: old_alter_table
Value: OFF
Variable_name: old_passwords
Value: ON
Variable_name: open_files_limit
Value: 40000
Variable_name: optimizer_prune_level
Value: 1
Variable_name: optimizer_search_depth
Value: 62
Variable_name: optimizer_switch
Value: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on
Variable_name: performance_schema
Value: OFF
Variable_name: performance_schema_events_waits_history_long_size
Value: 10000
Variable_name: performance_schema_events_waits_history_size
Value: 10
Variable_name: performance_schema_max_cond_classes
Value: 80
Variable_name: performance_schema_max_cond_instances
Value: 1000
Variable_name: performance_schema_max_file_classes
Value: 50
Variable_name: performance_schema_max_file_handles
Value: 32768
Variable_name: performance_schema_max_file_instances
Value: 10000
Variable_name: performance_schema_max_mutex_classes
Value: 200
Variable_name: performance_schema_max_mutex_instances
Value: 1000000
Variable_name: performance_schema_max_rwlock_classes
Value: 30
Variable_name: performance_schema_max_rwlock_instances
Value: 1000000
Variable_name: performance_schema_max_table_handles
Value: 100000
Variable_name: performance_schema_max_table_instances
Value: 50000
Variable_name: performance_schema_max_thread_classes
Value: 50
Variable_name: performance_schema_max_thread_instances
Value: 1000
Variable_name: pid_file
Value: /var/run/mysqld/mysqld.pid
Variable_name: plugin_dir
Value: /usr/lib/mysql/plugin/
Variable_name: port
Value: 3306
Variable_name: preload_buffer_size
Value: 32768
Variable_name: profiling
Value: OFF
Variable_name: profiling_history_size
Value: 15
Variable_name: protocol_version
Value: 10
Variable_name: proxy_user
Value:
Variable_name: pseudo_slave_mode
Value: OFF
Variable_name: pseudo_thread_id
Value: 30736
Variable_name: query_alloc_block_size
Value: 8192
Variable_name: query_cache_limit
Value: 8388608
Variable_name: query_cache_min_res_unit
Value: 4096
Variable_name: query_cache_size
Value: 0
Variable_name: query_cache_type
Value: ON
Variable_name: query_cache_wlock_invalidate
Value: OFF
Variable_name: query_prealloc_size
Value: 8192
Variable_name: rand_seed1
Value: 0
Variable_name: rand_seed2
Value: 0
Variable_name: range_alloc_block_size
Value: 4096
Variable_name: read_buffer_size
Value: 131072
Variable_name: read_only
Value: OFF
Variable_name: read_rnd_buffer_size
Value: 262144
Variable_name: relay_log
Value:
Variable_name: relay_log_index
Value:
Variable_name: relay_log_info_file
Value: relay-log.info
Variable_name: relay_log_purge
Value: ON
Variable_name: relay_log_recovery
Value: OFF
Variable_name: relay_log_space_limit
Value: 0
Variable_name: report_host
Value:
Variable_name: report_password
Value:
Variable_name: report_port
Value: 3306
Variable_name: report_user
Value:
Variable_name: rpl_recovery_rank
Value: 0
Variable_name: secure_auth
Value: OFF
Variable_name: secure_file_priv
Value:
Variable_name: server_id
Value: 7
Variable_name: skip_external_locking
Value: ON
Variable_name: skip_name_resolve
Value: OFF
Variable_name: skip_networking
Value: OFF
Variable_name: skip_show_database
Value: OFF
Variable_name: slave_compressed_protocol
Value: OFF
Variable_name: slave_exec_mode
Value: STRICT
Variable_name: slave_load_tmpdir
Value: /tmp
Variable_name: slave_max_allowed_packet
Value: 1073741824
Variable_name: slave_net_timeout
Value: 3600
Variable_name: slave_skip_errors
Value: OFF
Variable_name: slave_transaction_retries
Value: 10
Variable_name: slave_type_conversions
Value:
Variable_name: slow_launch_time
Value: 2
Variable_name: slow_query_log
Value: ON
Variable_name: slow_query_log_file
Value: /var/lib/mysql/db-nrlookup-slow.log
Variable_name: socket
Value: /var/run/mysqld/mysqld.sock
Variable_name: sort_buffer_size
Value: 2097152
Variable_name: sql_auto_is_null
Value: OFF
Variable_name: sql_big_selects
Value: ON
Variable_name: sql_big_tables
Value: OFF
Variable_name: sql_buffer_result
Value: OFF
Variable_name: sql_log_bin
Value: ON
Variable_name: sql_log_off
Value: OFF
Variable_name: sql_low_priority_updates
Value: OFF
Variable_name: sql_max_join_size
Value: 18446744073709551615
Variable_name: sql_mode
Value:
Variable_name: sql_notes
Value: ON
Variable_name: sql_quote_show_create
Value: ON
Variable_name: sql_safe_updates
Value: OFF
Variable_name: sql_select_limit
Value: 18446744073709551615
Variable_name: sql_slave_skip_counter
Value: 0
Variable_name: sql_warnings
Value: OFF
Variable_name: ssl_ca
Value:
Variable_name: ssl_capath
Value:
Variable_name: ssl_cert
Value:
Variable_name: ssl_cipher
Value:
Variable_name: ssl_key
Value:
Variable_name: storage_engine
Value: InnoDB
Variable_name: stored_program_cache
Value: 256
Variable_name: sync_binlog
Value: 0
Variable_name: sync_frm
Value: ON
Variable_name: sync_master_info
Value: 0
Variable_name: sync_relay_log
Value: 0
Variable_name: sync_relay_log_info
Value: 0
Variable_name: system_time_zone
Value: CET
Variable_name: table_definition_cache
Value: 400
Variable_name: table_open_cache
Value: 4096
Variable_name: thread_cache_size
Value: 64
Variable_name: thread_concurrency
Value: 10
Variable_name: thread_handling
Value: one-thread-per-connection
Variable_name: thread_stack
Value: 196608
Variable_name: time_format
Value: %H:%i:%s
Variable_name: time_zone
Value: SYSTEM
Variable_name: timed_mutexes
Value: OFF
Variable_name: timestamp
Value: 1385625067
Variable_name: tmp_table_size
Value: 16777216
Variable_name: tmpdir
Value: /tmp
Variable_name: transaction_alloc_block_size
Value: 8192
Variable_name: transaction_prealloc_size
Value: 4096
Variable_name: tx_isolation
Value: REPEATABLE-READ
Variable_name: unique_checks
Value: ON
Variable_name: updatable_views_with_limit
Value: YES
Variable_name: version
Value: 5.5.34-0ubuntu0.12.04.1-log
Variable_name: version_comment
Value: (Ubuntu)
Variable_name: version_compile_machine
Value: x86_64
Variable_name: version_compile_os
Value: debian-linux-gnu
Variable_name: wait_timeout
Value: 28800
Variable_name: warning_count
Value: 0
INT
(is it a number always?) and assign index to the column.networkoperator
,numbertype
FROMoch
.ochrange
WHERE 20972128 BETWEENrangestart
ANDrangeend
ORDER BYrangelength
ASC LIMIT 1;