public async Task InsertFromSelect() { if (KeepConnection) { await using var connection = new ClickHouseConnection(_connectionSettings); await connection.OpenAsync(); for (int i = 0; i < Rows; i++) { await using var cmd = connection.CreateCommand("INSERT INTO ColumnWriterInsertBenchmarks(id, str, dt, val) SELECT {id:UUID}, {str}, {dt}, {val}"); var idParam = new ClickHouseParameter("id") { Value = _id[i].ToString(), ClickHouseDbType = ClickHouseDbType.String }; cmd.Parameters.Add(idParam); var strParam = new ClickHouseParameter("str") { Value = _str[i], ClickHouseDbType = ClickHouseDbType.String }; cmd.Parameters.Add(strParam); var dtParam = new ClickHouseParameter("dt") { Value = _dt[i], ClickHouseDbType = ClickHouseDbType.DateTime }; cmd.Parameters.Add(dtParam); var valParam = new ClickHouseParameter("val") { Value = _val[i], ClickHouseDbType = ClickHouseDbType.Decimal }; cmd.Parameters.Add(valParam); await cmd.ExecuteNonQueryAsync(); } } else { for (int i = 0; i < Rows; i++) { await using var connection = new ClickHouseConnection(_connectionSettings); await connection.OpenAsync(); await using var cmd = connection.CreateCommand("INSERT INTO ColumnWriterInsertBenchmarks(id, str, dt, val) SELECT {id:UUID}, {str}, {dt}, {val}"); var idParam = new ClickHouseParameter("id") { Value = _id[i].ToString(), ClickHouseDbType = ClickHouseDbType.String }; cmd.Parameters.Add(idParam); var strParam = new ClickHouseParameter("str") { Value = _str[i], ClickHouseDbType = ClickHouseDbType.String }; cmd.Parameters.Add(strParam); var dtParam = new ClickHouseParameter("dt") { Value = _dt[i], ClickHouseDbType = ClickHouseDbType.DateTime }; cmd.Parameters.Add(dtParam); var valParam = new ClickHouseParameter("val") { Value = _val[i], ClickHouseDbType = ClickHouseDbType.Decimal }; cmd.Parameters.Add(valParam); await cmd.ExecuteNonQueryAsync(); if (!KeepConnection) { await cmd.DisposeAsync(); await connection.DisposeAsync(); } } } }