With a large volume of queries per second logging all queries gets expensive, it would be nice to be able to log only a configurable fraction of the queries, selected at random.
ProfileEvents::increment(ProfileEvents::InsertQueryTimeMicroseconds, query_time);
                }
                element.query_duration_ms = info.elapsed_seconds * 1000;
                element.read_rows = info.read_rows;
                element.read_bytes = info.read_bytes;
                element.written_rows = info.written_rows;
                element.written_bytes = info.written_bytes;
                element.memory_usage = info.peak_memory_usage > 0 ? info.peak_memory_usage : 0;
                element.thread_ids = std::move(info.thread_ids);
                element.profile_counters = std::move(info.profile_counters);
                
                
                const auto & access_info = context_ptr->getQueryAccessInfo();
                element.query_databases.insert(access_info.databases.begin(), access_info.databases.end());
                element.query_tables.insert(access_info.tables.begin(), access_info.tables.end());
                element.query_columns.insert(access_info.columns.begin(), access_info.columns.end());
                element.query_projections.insert(access_info.projections.begin(), access_info.projections.end());
                element.query_views.insert(access_info.views.begin(), access_info.views.end());
                const auto & factories_info = context_ptr->getQueryFactoriesInfo();
                element.used_aggregate_functions = factories_info.aggregate_functions;
                element.used_aggregate_function_combinators = factories_info.aggregate_function_combinators;
                element.used_database_engines = factories_info.database_engines;
                element.used_data_type_families = factories_info.data_type_families;
                element.used_dictionaries = factories_info.dictionaries;
                element.used_formats = factories_info.formats;
                element.used_functions = factories_info.functions;
                element.used_storages = factories_info.storages;
                element.used_table_functions = factories_info.table_functions;
            };