Project: ClickHouse (App Definition and Development / Database)
File: query_views_log.md

slug: /en/operations/system-tables/queryviewslog Contains information about the dependent views executed when running a query, for example, the view type or the execution time. To start logging: Configure parameters in the section. Set to 1. The flushing period of data is set in `flushintervalmilliseconds` parameter of the server settings section. To force flushing, use the query. ClickHouse does not delete data from the table automatically. See for more details. You can use the setting to reduce the number of queries, registered in the `queryviewslog` table. Columns: `hostname` () Hostname of the server executing the query. `event_date` () The date when the last event of the view happened. `event_time` () The date and time when the view finished execution. `eventtimemicroseconds` () The date and time when the view finished execution with microseconds precision. `viewdurationms` () Duration of view execution (sum of its stages) in milliseconds. `initialqueryid` () ID of the initial query (for distributed query execution). `view_name` () Name of the view. `view_uuid` () UUID of the view. `view_type` () Type of the view. Values: `'Default' = 1` . Should not appear in this log. `'Materialized' = 2` . `'Live' = 3` . `view_query` () The query executed by the view. `view_target` () The name of the view target table. `read_rows` () Number of read rows. `read_bytes` () Number of read bytes. `written_rows` () Number of written rows. `written_bytes` () Number of written bytes. `peakmemoryusage` () The maximum difference between the amount of allocated and freed memory in context of this view. `ProfileEvents` () ProfileEvents that measure different metrics. The description of them could be found in the table . `status` () Status of the view. Values: `'QueryStart' = 1` Successful start the view execution. Should not appear. `'QueryFinish' = 2` Successful end of the view execution. `'ExceptionBeforeStart' = 3` Exception before the start of the view execution. `'ExceptionWhileProcessing' = 4` Exception during the view execution. `exception_code` () Code of an exception. `exception` () Exception message. `stack_trace` () . An empty string, if the query was completed successfully. Example Query: ``` sql SELECT * FROM system.queryviewslog LIMIT 1 \G; ``` Result: ``` text Row 1: hostname: clickhouse.eu-central1.internal event_date: 2021-06-22 event_time: 2021-06-22 13:23:07 eventtimemicroseconds: 2021-06-22 13:23:07.738221 viewdurationms: 0 initialqueryid: c3a1ac02-9cad-479b-af54-9e9c0a7afd70 viewname: default.matviewinner view_uuid: 00000000-0000-0000-0000-000000000000 view_type: Materialized viewquery: SELECT * FROM default.tableb viewtarget: default.`.inner.matviewinner` read_rows: 4 read_bytes: 64 written_rows: 2 written_bytes: 32 peakmemoryusage: 4196188 ProfileEvents: {'FileOpen':2,'WriteBufferFromFileDescriptorWrite':2,'WriteBufferFromFileDescriptorWriteBytes':187,'IOBufferAllocs':3,'IOBufferAllocBytes':3145773,'FunctionExecute':3,'DiskWriteElapsedMicroseconds':13,'InsertedRows':2,'InsertedBytes':16,'SelectedRows':4,'SelectedBytes':48,'ContextLock':16,'RWLockAcquiredReadLocks':1,'RealTimeMicroseconds':698,'SoftPageFaults':4,'OSReadChars':463} status: QueryFinish exception_code: 0 exception: stack_trace: ``` See Also Description of the `query_log` system table which contains common information about queries execution. This table contains information about each query execution thread.