Computer >> 컴퓨터 >  >> 프로그램 작성 >> MySQL

MySQL에서 읽기/쓰기 비율을 확인하는 명령?

<시간/>

읽기/쓰기 비율을 확인하려면 SHOW STATUS 명령을 사용해야 합니다. 이렇게 하면 모든 비율이 표시됩니다.

사례 1 − 읽기/쓰기 비율을 구하는 구문은 다음과 같습니다. −

SHOW STATUS LIKE ‘Com_%’;

사례 2 − 삽입, 업데이트, 선택 및 삭제 비율을 원하면 아래 구문을 사용하십시오. −

SHOW GLOBAL STATUS WHERE Variable_name = 'Com_insert'
OR Variable_name = 'Com_select' OR
Variable_name = 'Com_Update' OR Variable_name = 'Com_delete';

여기서 위의 구문을 변경할 필요가 없습니다. 쿼리는 다음과 같습니다 -

mysql> SHOW GLOBAL STATUS WHERE Variable_name = 'Com_insert' OR Variable_name
= 'Com_select' OR
   -> Variable_name = 'Com_Update' OR Variable_name = 'Com_delete';

다음은 출력입니다 -

+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Com_delete    | 5     |
| Com_insert    | 340   |
| Com_select    | 286   |
| Com_update    | 13    |
+---------------+-------+
4 rows in set (0.00 sec)

모든 정보를 원하면 위의 구문을 사용하십시오. 쿼리는 다음과 같습니다 -

mysql> Show status like 'Com_%';

다음은 출력입니다 -

+-------------------------------------+-------+
| Variable_name                       | Value |
+-------------------------------------+-------+
| Com_admin_commands                  | 0     |
| Com_assign_to_keycache              | 0     |
| Com_alter_db                        | 0     |
| Com_alter_event                     | 0     |
| Com_alter_function                  | 0     |
| Com_alter_instance                  | 0     |
| Com_alter_procedure                 | 0     |
| Com_alter_resource_group            | 0     |
| Com_alter_server                    | 0     |
| Com_alter_table                     | 0     |
| Com_alter_tablespace                | 0     |
| Com_alter_user                      | 0     |
| Com_alter_user_default_role         | 0     |
| Com_analyze                         | 0     |
| Com_begin                           | 0     |
| Com_binlog                          | 0     |
| Com_call_procedure                  | 0     |
| Com_change_db                       | 1     |
| Com_change_master                   | 0     |
| Com_change_repl_filter              | 0     |
| Com_check                           | 0     |
| Com_checksum                        | 0     |
| Com_clone                           | 0     |
| Com_commit                          | 0     |
| Com_create_db                       | 0     |
| Com_create_event                    | 0     |
| Com_create_function                 | 0     |
| Com_create_index                    | 0     |
| Com_create_procedure                | 0     |
| Com_create_role                     | 0     |
| Com_create_server                   | 0     |
| Com_create_table                    | 6     |
| Com_create_resource_group           | 0     |
| Com_create_trigger                  | 0     |
| Com_create_udf                      | 0     |
| Com_create_user                     | 0     |
| Com_create_view                     | 0     |
| Com_create_spatial_reference_system | 0     |
| Com_dealloc_sql                     | 0     |
| Com_delete                          | 0     |
| Com_delete_multi                    | 0     |
| Com_do                              | 0     |
| Com_drop_db                         | 0     |
| Com_drop_event                      | 0     |
| Com_drop_function                   | 0     |
| Com_drop_index                      | 0     |
| Com_drop_procedure                  | 0     |
| Com_drop_resource_group             | 0     |
| Com_drop_role                       | 0     |
| Com_drop_server                     | 0     |
| Com_drop_spatial_reference_system   | 0     |
| Com_drop_table                      | 0     |
| Com_drop_trigger                    | 0     |
| Com_drop_user                       | 0     |
| Com_drop_view                       | 0     |
| Com_empty_query                     | 0     |
| Com_execute_sql                     | 0     |
| Com_explain_other                   | 0     |
| Com_flush                           | 0     |
| Com_get_diagnostics                 | 0     |
| Com_grant                           | 0     |
| Com_grant_roles                     | 0     |
| Com_ha_close                        | 0     |
| Com_ha_open                         | 0     |
| Com_ha_read                         | 0     |
| Com_help                            | 0     |
| Com_import                          | 0     |
| Com_insert                          | 42    |
| Com_insert_select                   | 0     |
| Com_install_component               | 0     |
| Com_install_plugin                  | 0     |
| Com_kill                            | 0     |
| Com_load                            | 0     |
| Com_lock_instance                   | 0     |
| Com_lock_tables                     | 0     |
| Com_optimize                        | 0     |
| Com_preload_keys                    | 0     |
| Com_prepare_sql                     | 0     |
| Com_purge                           | 0     |
| Com_purge_before_date               | 0     |
| Com_release_savepoint               | 0     |
| Com_rename_table                    | 0     |
| Com_rename_user                     | 0     |
| Com_repair                          | 0     |
| Com_replace                         | 0     |
| Com_replace_select                  | 0     |
| Com_reset                           | 0     |
| Com_resignal                        | 0     |
| Com_restart                         | 0     |
| Com_revoke                          | 0     |
| Com_revoke_all                      | 0     |
| Com_revoke_roles                    | 0     |
| Com_rollback                        | 0     |
| Com_rollback_to_savepoint           | 0     |
| Com_savepoint                       | 0     |
| Com_select                          | 27    |
| Com_set_option                      | 3     |
| Com_set_password                    | 0     |
| Com_set_resource_group              | 0     |
| Com_set_role                        | 0     |
| Com_signal                          | 0     |
| Com_show_binlog_events              | 0     |
| Com_show_binlogs                    | 0     |
| Com_show_charsets                   | 0     |
| Com_show_collations                 | 0     |
| Com_show_create_db                  | 0     |
| Com_show_create_event               | 0     |
| Com_show_create_func                | 0     |
| Com_show_create_proc                | 0     |
| Com_show_create_table               | 0     |
| Com_show_create_trigger             | 0     |
| Com_show_databases                  | 0     |
| Com_show_engine_logs                | 0     |
| Com_show_engine_mutex               | 0     |
| Com_show_engine_status              | 0     |
| Com_show_events                     | 0     |
| Com_show_errors                     | 0     |
| Com_show_fields                     | 0     |
| Com_show_function_code              | 0     |
| Com_show_function_status            | 0     |
| Com_show_grants                     | 0     |
| Com_show_keys                       | 0     |
| Com_show_master_status              | 0     |
| Com_show_open_tables                | 0     |
| Com_show_plugins                    | 0     |
| Com_show_privileges                 | 0     |
| Com_show_procedure_code             | 0     |
| Com_show_procedure_status           | 0     |
| Com_show_processlist                | 0     |
| Com_show_profile                    | 0     |
| Com_show_profiles                   | 0     |
| Com_show_relaylog_events            | 0     |
| Com_show_slave_hosts                | 0     |
| Com_show_slave_status               | 0     |
| Com_show_status                     | 3     |
| Com_show_storage_engines            | 0     |
| Com_show_table_status               | 0     |
| Com_show_tables                     | 0     |
| Com_show_triggers                   | 0     |
| Com_show_variables                  | 2     |
| Com_show_warnings                   | 0     |
| Com_show_create_user                | 0     |
| Com_shutdown                        | 0     |
| Com_slave_start                     | 0     |
| Com_slave_stop                      | 0     |
| Com_group_replication_start         | 0     |
| Com_group_replication_stop          | 0     |
| Com_stmt_execute                    | 0     |
| Com_stmt_close                      | 0     |
| Com_stmt_fetch                      | 0     |
| Com_stmt_prepare                    | 0     |
| Com_stmt_reset                      | 0     |
| Com_stmt_send_long_data             | 0     |
| Com_truncate                        | 0     |
| Com_uninstall_component             | 0     |
| Com_uninstall_plugin                | 0     |
| Com_unlock_instance                 | 0     |
| Com_unlock_tables                   | 0     |
| Com_update                          | 0     |
| Com_update_multi                    | 0     |
| Com_xa_commit                       | 0     |
| Com_xa_end                          | 0     |
| Com_xa_prepare                      | 0     |
| Com_xa_recover                      | 0     |
| Com_xa_rollback                     | 0     |
| Com_xa_start                        | 0     |
| Com_stmt_reprepare                  | 0     |
| Compression                         | OFF   |
+-------------------------------------+-------+
168 rows in set (0.04 sec)