我在网上广泛搜索,没有看到其他人发帖,所以我想我会的。我正在尝试审核查询存储何时进行清理并从查询存储中清除。
我发现有两个扩展的事件会话,我认为是事件,但即使查询存储清除了陈旧的查询数据,我也没有获取任何数据:
- query_store_db_cleanup_started
- query_store_db_cleanup_finished
想知道当查询存储清除其数据时,是否还有其他人遇到过同样的问题并且和我一样好奇?
以下是我用于设置当前审计的代码:
CREATE EVENT SESSION [QueryStore_Cleanup_Audit] ON SERVER ADD EVENT qds.query_store_db_cleanup__finished (ACTION ( package0.last_error, package0.process_id, sqlos.cpu_id, sqlos.system_thread_id, sqlos.task_time, sqlserver.client_app_name, sqlserver.client_connection_id, sqlserver.client_hostname, sqlserver.client_pid, sqlserver.context_info, sqlserver.database_id, sqlserver.database_name, sqlserver.nt_username, sqlserver.plan_handle, sqlserver.server_instance_name, sqlserver.session_id, sqlserver.session_nt_username, sqlserver.sql_text, sqlserver.transaction_id, sqlserver.username ) WHERE ([database_id] = (5)) ), ADD EVENT qds.query_store_db_cleanup__started (ACTION ( package0.last_error, package0.process_id, sqlos.cpu_id, sqlos.system_thread_id, sqlos.task_time, sqlserver.client_app_name, sqlserver.client_connection_id, sqlserver.client_hostname, sqlserver.client_pid, sqlserver.context_info, sqlserver.database_id, sqlserver.database_name, sqlserver.nt_username, sqlserver.plan_handle, sqlserver.server_instance_name, sqlserver.session_id, sqlserver.session_nt_username, sqlserver.sql_text, sqlserver.transaction_id, sqlserver.username ) WHERE ([database_id] = (5)) ) WITH ( MAX_MEMORY = 40096KB, EVENT_RETENTION_MODE = ALLOW_SINGLE_EVENT_LOSS, MAX_DISPATCH_LATENCY = 30 SECONDS, MAX_EVENT_SIZE = 0KB, MEMORY_PARTITION_MODE = NONE, TRACK_CAUSALITY = OFF, STARTUP_STATE = ON ); GO query_store_db_cleanup_started
编辑 - 10/8/18 - 我终于能够通过 EE 跟踪清理事件!下面是我的代码,因为我缺少“query_store_plan_removal”和“query_store_size_retention_cleanup_update”EE 事件:
CREATE EVENT SESSION [QueryStore_Cleanup_Audit] ON SERVER ADD EVENT qds.query_store_db_cleanup__finished (ACTION ( package0.last_error, package0.process_id, sqlos.cpu_id, sqlos.system_thread_id, sqlos.task_time, sqlserver.client_app_name, sqlserver.client_connection_id, sqlserver.client_hostname, sqlserver.client_pid, sqlserver.context_info, sqlserver.database_id, sqlserver.database_name, sqlserver.nt_username, sqlserver.plan_handle, sqlserver.server_instance_name, sqlserver.session_id, sqlserver.session_nt_username, sqlserver.sql_text, sqlserver.transaction_id, sqlserver.username ) ), ADD EVENT qds.query_store_db_cleanup__started (ACTION ( package0.last_error, package0.process_id, sqlos.cpu_id, sqlos.system_thread_id, sqlos.task_time, sqlserver.client_app_name, sqlserver.client_connection_id, sqlserver.client_hostname, sqlserver.client_pid, sqlserver.context_info, sqlserver.database_id, sqlserver.database_name, sqlserver.nt_username, sqlserver.plan_handle, sqlserver.server_instance_name, sqlserver.session_id, sqlserver.session_nt_username, sqlserver.sql_text, sqlserver.transaction_id, sqlserver.username ) ), ADD EVENT qds.query_store_execution_runtime_info_discarded (ACTION ( sqlos.task_time, sqlserver.database_id, sqlserver.database_name, sqlserver.plan_handle, sqlserver.query_hash, sqlserver.session_id, sqlserver.sql_text, sqlserver.username ) ), ADD EVENT qds.query_store_flush_failed (ACTION ( sqlserver.database_id, sqlserver.database_name, sqlserver.nt_username, sqlserver.plan_handle, sqlserver.query_hash, sqlserver.query_plan_hash_signed, sqlserver.sql_text, sqlserver.username ) ), ADD EVENT qds.query_store_plan_removal (ACTION ( sqlos.task_time, sqlserver.database_id, sqlserver.database_name, sqlserver.nt_username, sqlserver.plan_handle, sqlserver.query_plan_hash_signed, sqlserver.sql_text, sqlserver.username ) ), ADD EVENT qds.query_store_size_retention_cleanup_finished (ACTION ( sqlos.task_time, sqlserver.database_id, sqlserver.database_name, sqlserver.nt_username, sqlserver.plan_handle, sqlserver.query_hash, sqlserver.query_plan_hash_signed, sqlserver.username ) ), ADD EVENT qds.query_store_size_retention_cleanup_skipped (ACTION ( sqlos.task_time, sqlserver.database_id, sqlserver.database_name, sqlserver.nt_username, sqlserver.query_plan_hash_signed, sqlserver.session_id, sqlserver.sql_text, sqlserver.username ) ), ADD EVENT qds.query_store_size_retention_cleanup_started (ACTION ( sqlos.task_time, sqlserver.database_id, sqlserver.database_name, sqlserver.nt_username, sqlserver.plan_handle, sqlserver.query_hash, sqlserver.query_plan_hash_signed, sqlserver.username ) ), ADD EVENT qds.query_store_size_retention_cleanup_update (ACTION ( sqlos.task_time, sqlserver.database_id, sqlserver.database_name, sqlserver.nt_username, sqlserver.plan_handle, sqlserver.query_plan_hash_signed, sqlserver.sql_text, sqlserver.username ) ), ADD EVENT qds.query_store_size_retention_query_deleted (ACTION ( sqlos.task_time, sqlserver.database_id, sqlserver.database_name, sqlserver.nt_username, sqlserver.plan_handle, sqlserver.query_hash, sqlserver.sql_text, sqlserver.username ) ) WITH ( MAX_MEMORY = 40096KB, EVENT_RETENTION_MODE = ALLOW_SINGLE_EVENT_LOSS, MAX_DISPATCH_LATENCY = 30 SECONDS, MAX_EVENT_SIZE = 0KB, MEMORY_PARTITION_MODE = NONE, TRACK_CAUSALITY = OFF, STARTUP_STATE = ON ); GO