MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / execute

Method execute

programs/benchmark/Benchmark.cpp:717–805  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

715 }
716
717 void execute(const Query & query, size_t connection_index)
718 {
719 Stopwatch watch;
720
721 std::shared_ptr<IntervalStats> cur_interval;
722 if (precise)
723 {
724 std::lock_guard lock(interval_mutex);
725 cur_interval = interval;
726 }
727
728 ConnectionPool::Entry entry = connections[connection_index]->get(ConnectionTimeouts::getTCPTimeoutsWithoutFailover(settings));
729
730 bool should_reconnect = false;
731 {
732 std::lock_guard lock(queries_per_connection_mutex);
733 should_reconnect = reconnect > 0 && (++queries_per_connection[connection_index] % reconnect == 0);
734 }
735
736 if (should_reconnect)
737 entry->disconnect();
738
739 RemoteQueryExecutor executor(*entry, query, std::make_shared<const Block>(), global_context, nullptr, Scalars(), Tables(), query_processing_stage);
740
741 if (!query_id.empty())
742 executor.setQueryId(query_id);
743 else if (!query_id_prefix.empty())
744 executor.setQueryId(query_id_prefix + "_" + Poco::UUIDGenerator().createRandom().toString());
745
746 Progress progress;
747 executor.setProgressCallback([&progress](const Progress & value) { progress.incrementPiecewiseAtomically(value); });
748
749 executor.sendQuery(ClientInfo::QueryKind::INITIAL_QUERY);
750
751 ProfileInfo info;
752 for (Block block = executor.readBlock(); !block.empty(); block = executor.readBlock())
753 info.update(block);
754
755 executor.finish();
756
757 watch.stop();
758 double duration = (display_client_side_time || progress.elapsed_ns == 0)
759 ? watch.elapsedSeconds()
760 : static_cast<double>(progress.elapsed_ns) / 1e9;
761 size_t info_index = round_robin ? 0 : connection_index;
762
763 if (precise && cur_interval)
764 {
765 // Stats weighting across all overlapped intervals
766 UInt64 duration_ns = watch.getEnd() - watch.getStart();
767
768 std::lock_guard lock(interval_mutex);
769
770 // Distribute weights across intervals intersecting query execution span
771 // Intervals:
772 // [beg] I0: [s0---------e0)
773 // I1: [s1--------------e1)
774 // [end] I2: | [s2-----------e2)

Callers

nothing calls this directly

Calls 15

createRandomMethod · 0.80
getEndMethod · 0.80
getStartMethod · 0.80
addWeightedMethod · 0.80
minFunction · 0.50
maxFunction · 0.50
getMethod · 0.45
disconnectMethod · 0.45
emptyMethod · 0.45
setQueryIdMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected