sql - DBMS Query Log, is it possible? -
we want record db query log table, possible?
from sql server perspective......
as others have suggested, sql server profiler 1 way go you're going incur resource hit doing so. should choose method absolutely must implement server side trace rather via gui.
you may have success monitoring, recording contents of dynamic management views (dmv) things such query execution statistics.
you'll want @ dmv's such as:
for example, here query can used identify poorest performing top 20 sql queries cpu consumption. not after demonstrate how use dmv's interested in.
select top 20 qs.sql_handle, qs.execution_count, qs.total_worker_time total_cpu, total_cpu_inseconds = --converted microseconds qs.total_worker_time/1000000, average_cpu_inseconds = --converted microseconds (qs.total_worker_time/1000000) / qs.execution_count, qs.total_elapsed_time, total_elapsed_time_inseconds = --converted microseconds qs.total_elapsed_time/1000000, st.text, qp.query_plan sys.dm_exec_query_stats qs cross apply sys.dm_exec_sql_text(qs.sql_handle) st cross apply sys.dm_exec_query_plan (qs.plan_handle) qp order qs.total_worker_time desc
Comments
Post a Comment