@@ -6,16 +6,14 @@ import FunctionDescription from '@site/src/components/FunctionDescription';
66
77<FunctionDescription description =" Introduced or updated: v1.2.696 " />
88
9- A read-only in-memory table stores all the query logs.
10-
9+ A read-only in-memory table stores all the query logs. For the specific fields available in the query logs, refer to the [ Examples] ( #examples ) section.
1110
1211## Setting a Session Tag
1312
14- You can optionally assign a tag to your session, making it easier to filter logs in the log table based on the assigned session tag. For example, the following assigns the tag ‘ eric’ to the current session:
13+ You can optionally assign a tag to your session, making it easier to filter logs in the log table based on the assigned session tag. For example, the following assigns the tag ` eric ` to the current session:
1514
1615``` sql
1716set session query_tag= ' eric' ;
18-
1917```
2018
2119We can then run a query and retrieve the log from the log table using the assigned tag:
@@ -24,7 +22,6 @@ We can then run a query and retrieve the log from the log table using the assign
2422show users;
2523
2624select query_tag, query_text from system .query_log where query_tag= ' eric' limit 1 ;
27-
2825```
2926
3027In the returned result, you can find the record for the query, tagged as 'eric':
@@ -37,29 +34,33 @@ In the returned result, you can find the record for the query, tagged as 'eric':
3734
3835## Examples
3936
37+ The ` system.query_log ` table stores detailed logs of executed queries. Here's an example of what the log entry looks like:
38+
4039``` sql
41- SELECT * FROM system .query_log LIMIT 1 ;
40+ SELECT * FROM system .query_log ;
41+ ```
4242
43- - [ RECORD 1 ]-- ---------------------------------
44- log_type: 1
45- log_type_name: Start
43+ ``` sql
44+ ...
45+ - [ RECORD 10 ]-- ---------------------------------
46+ log_type: 2
47+ log_type_name: Finish
4648 handler_type: HTTPQuery
4749 tenant_id: default
4850 cluster_id: default
49- node_id: zv3rra2vO7f9WUgqIu8WH
51+ node_id: bwElPLZxWt0F8LOFAqsIL2
5052 sql_user: root
5153 sql_user_quota: UserQuota< cpu:0 ,mem:0 ,store:0 >
5254 sql_user_privileges: GRANT ALL ON * .* , ROLES: [" account_admin" ]
53- query_tag:
54- query_id: 7e03cd7a- 36fa- 463d- afe4- 041da4092c45
55+ query_id: 1957f343- 564e- 471f- b036- a10ff853357e
5556 query_kind: Other
56- query_text: SHOW TABLES
57- query_hash: 9c36cac1372650b703400c60dd29042c
58- query_parameterized_hash: 9c36cac1372650b703400c60dd29042c
59- event_date: 2024 - 07 - 30
60- event_time: 2024 - 07 - 30 04 : 27 : 29 . 296596
61- query_start_time: 2024 - 07 - 30 04 : 27 : 29 . 252170
62- query_duration_ms: 0
57+ query_text: SHOW USERS
58+ query_hash: 63c65a28ae257d780e93a8a627190775
59+ query_parameterized_hash: 63c65a28ae257d780e93a8a627190775
60+ event_date: 2025 - 04 - 27
61+ event_time: 2025 - 04 - 27 16 : 59 : 31 . 681036
62+ query_start_time: 2025 - 04 - 27 16 : 59 : 31 . 671825
63+ query_duration_ms: 9
6364query_queued_duration_ms: 0
6465 current_database: default
6566 databases:
@@ -76,27 +77,29 @@ query_queued_duration_ms: 0
7677 group_by_spilled_bytes: 0
7778 written_io_bytes: 0
7879written_io_bytes_cost_ms: 0
79- scan_rows: 0
80- scan_bytes: 0
80+ scan_rows: 1
81+ scan_bytes: 164
8182 scan_io_bytes: 0
8283 scan_io_bytes_cost_ms: 0
8384 scan_partitions: 0
8485 total_partitions: 0
85- result_rows: 0
86- result_bytes: 0
86+ result_rows: 1
87+ result_bytes: 146
8788 cpu_usage: 8
8889 memory_usage: 0
8990 bytes_from_remote_disk: 0
9091 bytes_from_local_disk: 0
9192 bytes_from_memory: 0
9293 client_info:
9394 client_address: 192 .168 .65 .1
94- user_agent: bendsql/ 0 .19 . 2 - 1e338e1
95+ user_agent: bendsql/ 0 .24 . 1 - f1f7de0
9596 exception_code: 0
9697 exception_text:
9798 stack_trace:
98- server_version: v1 .2 .583 - nightly- 03c09a571d(rust- 1 .81 .0 - nightly- 2024 - 07 - 25T22:12 :15 .571684726Z)
99- session_settings: acquire_lock_timeout=30, aggregate_spilling_bytes_threshold_per_proc=0, aggregate_spilling_memory_ratio=60, auto_compaction_imperfect_blocks_threshold=25, collation=utf8, compact_max_block_selection=10000, cost_factor_aggregate_per_row=5, cost_factor_hash_table_per_row=10, cost_factor_network_per_row=50, create_query_flight_client_with_current_rt=1, data_retention_time_in_days=1, ddl_column_type_nullable=1, disable_join_reorder=0, disable_merge_into_join_reorder=0, disable_variant_check=0, efficiently_memory_group_by=0, enable_aggregating_index_scan=1, enable_auto_fix_missing_bloom_index=0, enable_bloom_runtime_filter=1, enable_cbo=1, enable_clickhouse_handler=0, enable_compact_after_write=1, enable_distributed_compact=0, enable_distributed_copy_into=1, enable_distributed_merge_into=1, enable_distributed_recluster=0, enable_distributed_replace_into=0, enable_dphyp=1, enable_dst_hour_fix=0, enable_experimental_aggregate_hashtable=1, enable_experimental_merge_into=1, enable_experimental_queries_executor=0, enable_experimental_rbac_check=1, enable_geo_create_table=0, enable_hive_parquet_predict_pushdown=1, enable_loser_tree_merge_sort=0, enable_merge_into_row_fetch=1, enable_new_copy_for_text_formats=1, enable_parquet_page_index=1, enable_parquet_prewhere=0, enable_parquet_rowgroup_pruning=1, enable_query_result_cache=0, enable_refresh_aggregating_index_after_write=1, enable_refresh_virtual_column_after_write=1, enable_replace_into_partitioning=1, enable_strict_datetime_parser=1, enable_table_lock=1, enforce_broadcast_join=0, external_server_connect_timeout_secs=10, external_server_request_batch_rows=65536, external_server_request_timeout_secs=180, flight_client_timeout=60, format_null_as_str=1, geometry_output_format=GeoJSON, group_by_shuffle_mode=before_merge, group_by_two_level_threshold=20000, hide_options_in_show_create_table=1, hive_parquet_chunk_size=16384, http_handler_result_timeout_secs=60, idle_transaction_timeout_secs=14400, inlist_to_join_threshold=1024, input_read_buffer_size=4194304, join_spilling_buffer_threshold_per_proc_mb=1024, join_spilling_bytes_threshold_per_proc=0, join_spilling_memory_ratio=60, join_spilling_partition_bits=4, lazy_read_threshold=1000, load_file_metadata_expire_hours=24, max_block_size=65536, max_cte_recursive_depth=1000, max_execute_time_in_seconds=0, max_inlist_to_or=3, max_memory_usage=6577507532, max_result_rows=0, max_set_operator_count=18446744073709551615, max_storage_io_requests=48, max_threads=8, max_vacuum_temp_files_after_query=18446744073709551615, numeric_cast_option=rounding, parquet_fast_read_bytes=16777216, parquet_max_block_size=8192, parse_datetime_ignore_remainder=1, prefer_broadcast_join=1, purge_duplicated_files_in_copy=0, query_flight_compression=LZ4, query_result_cache_allow_inconsistent=0, query_result_cache_max_bytes=1048576, query_result_cache_min_execute_secs=1, query_result_cache_ttl_secs=300, quoted_ident_case_sensitive=1, recluster_block_size=2104802410, recluster_timeout_secs=43200, replace_into_bloom_pruning_max_column_number=4, replace_into_shuffle_strategy=0, sandbox_tenant=, script_max_steps=10000, sort_spilling_batch_bytes=8388608, sort_spilling_bytes_threshold_per_proc=0, sort_spilling_memory_ratio=60, sql_dialect=PostgreSQL, statement_queued_timeout_in_seconds=0, storage_fetch_part_num=2, storage_io_max_page_bytes_for_read=524288, storage_io_min_bytes_for_seek=48, storage_read_buffer_size=1048576, table_lock_expire_secs=20, timezone=UTC, unquoted_ident_case_sensitive=0, use_parquet2=0, scope: SESSION
99+ server_version: v1 .2 .731 - nightly- eb671da5e5(rust- 1 .88 .0 - nightly- 2025 - 04 - 27T06:06 :12 .942159732Z)
100+ query_tag: eric
101+ session_settings: acquire_lock_timeout=30, aggregate_spilling_memory_ratio=60, auto_compaction_imperfect_blocks_threshold=25, auto_compaction_segments_limit=3, collation=utf8, compact_max_block_selection=10000, copy_dedup_full_path_by_default=0, cost_factor_aggregate_per_row=5, cost_factor_hash_table_per_row=10, cost_factor_network_per_row=50, create_query_flight_client_with_current_rt=1, data_retention_time_in_days=1, ddl_column_type_nullable=1, default_order_by_null=nulls_last, disable_join_reorder=0, disable_variant_check=0, dynamic_sample_time_budget_ms=0, efficiently_memory_group_by=0, enable_aggregating_index_scan=1, enable_analyze_histogram=0, enable_auto_fix_missing_bloom_index=0, enable_auto_vacuum=0, enable_block_stream_write=0, enable_bloom_runtime_filter=1, enable_cbo=1, enable_clickhouse_handler=0, enable_compact_after_multi_table_insert=0, enable_compact_after_write=1, enable_dio=1, enable_distributed_compact=0, enable_distributed_copy_into=1, enable_distributed_merge_into=1, enable_distributed_pruning=1, enable_distributed_recluster=0, enable_distributed_replace_into=0, enable_dphyp=1, enable_dst_hour_fix=0, enable_expand_roles=1, enable_experimental_aggregate_hashtable=1, enable_experimental_merge_into=1, enable_experimental_procedure=0, enable_experimental_queries_executor=0, enable_experimental_rbac_check=1, enable_geo_create_table=0, enable_hive_parquet_predict_pushdown=1, enable_last_snapshot_location_hint=1, enable_loser_tree_merge_sort=1, enable_materialized_cte=1, enable_merge_into_row_fetch=1, enable_new_copy_for_text_formats=1, enable_optimizer_trace=0, enable_parallel_multi_merge_sort=1, enable_parquet_page_index=1, enable_parquet_prewhere=0, enable_parquet_rowgroup_pruning=1, enable_planner_cache=1, enable_prune_cache=1, enable_prune_pipeline=1, enable_query_result_cache=0, enable_refresh_aggregating_index_after_write=1, enable_refresh_virtual_column_after_write=1, enable_replace_into_partitioning=1, enable_strict_datetime_parser=1, enable_table_lock=1, enforce_broadcast_join=0, enforce_shuffle_join=0, error_on_nondeterministic_update=1, external_server_connect_timeout_secs=10, external_server_request_batch_rows=65536, external_server_request_max_threads=256, external_server_request_retry_times=8, external_server_request_timeout_secs=180, flight_client_timeout=60, flight_connection_max_retry_times=0, flight_connection_retry_interval=1, force_aggregate_data_spill=0, force_join_data_spill=0, force_sort_data_spill=0, force_window_data_spill=0, format_null_as_str=1, geometry_output_format=GeoJSON, group_by_shuffle_mode=before_merge, group_by_two_level_threshold=20000, hide_options_in_show_create_table=1, hilbert_clustering_min_bytes=107374182400, hilbert_num_range_ids=1000, hilbert_sample_size_per_block=1000, hive_parquet_chunk_size=16384, http_handler_result_timeout_secs=60, idle_transaction_timeout_secs=14400, inlist_to_join_threshold=1024, input_read_buffer_size=4194304, join_spilling_buffer_threshold_per_proc_mb=512, join_spilling_memory_ratio=60, join_spilling_partition_bits=4, lazy_read_threshold=1000, load_file_metadata_expire_hours=24, max_block_size=65536, max_cte_recursive_depth=1000, max_execute_time_in_seconds=0, max_inlist_to_or=3, max_memory_usage=6574653440, max_push_down_limit=10000, max_query_memory_usage=0, max_result_rows=0, max_set_operator_count=18446744073709551615, max_spill_io_requests=48, max_storage_io_requests=48, max_threads=8, max_vacuum_temp_files_after_query=18446744073709551615, network_policy=, numeric_cast_option=rounding, optimizer_skip_list=, parquet_fast_read_bytes=16777216, parquet_max_block_size=8192, parse_datetime_ignore_remainder=1, persist_materialized_cte=0, prefer_broadcast_join=1, purge_duplicated_files_in_copy=0, query_flight_compression=LZ4, query_out_of_memory_behavior=throw, query_result_cache_allow_inconsistent=0, query_result_cache_max_bytes=1048576, query_result_cache_min_execute_secs=1, query_result_cache_ttl_secs=300, query_tag=eric, quoted_ident_case_sensitive=1, random_function_seed=0, recluster_block_size=1972396032, recluster_timeout_secs=43200, replace_into_bloom_pruning_max_column_number=4, replace_into_shuffle_strategy=0, sandbox_tenant=, script_max_steps=10000, short_sql_max_length=128, sort_spilling_batch_bytes=8388608, sort_spilling_memory_ratio=60, spilling_file_format=parquet, spilling_to_disk_vacuum_unknown_temp_dirs_limit=18446744073709551615, sql_dialect=PostgreSQL, statement_queue_ttl_in_seconds=15, statement_queued_timeout_in_seconds=0, storage_fetch_part_num=2, storage_io_max_page_bytes_for_read=524288, storage_io_min_bytes_for_seek=48, storage_read_buffer_size=1048576, stream_consume_batch_size_hint=0, table_lock_expire_secs=30, timezone=UTC, unquoted_ident_case_sensitive=0, use_parquet2=0, use_vacuum2_to_purge_transient_table_data=0, warehouse=, window_num_partitions=256, window_partition_sort_block_size=65536, window_partition_spilling_memory_ratio=60, window_partition_spilling_to_disk_bytes_limit=0, window_spill_unit_size_mb=256, scope: SESSION
100102 extra:
101- has_profile: false
103+ has_profile: true
104+ peek_memory_usage: {" bwElPLZxWt0F8LOFAqsIL2" :576850 }
102105```
0 commit comments