mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-13 09:52:38 +00:00
4f41ebcae3
Default settings are not very efficient, since they do not even reuse connections. And when each query requires connection you can have only ~80 QPS, while by simply enabling connection reuse (connection_auto_close=false) you can have ~500 QPS (and by increasing connection_pool_size you can have better QPS throughput). So this patch allows to pass through some connection related settings for the StorageMySQL engine, like: - connection_pool_size=16 - connection_max_tries=3 - connection_auto_close=true v2: remove connection_pool_default_size v3: remove num_tries_on_connection_loss
69 lines
1.8 KiB
C++
69 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#if !defined(ARCADIA_BUILD)
|
|
#include "config_core.h"
|
|
#endif
|
|
|
|
#if USE_MYSQL
|
|
|
|
#include <ext/shared_ptr_helper.h>
|
|
|
|
#include <Storages/IStorage.h>
|
|
#include <Storages/MySQL/MySQLSettings.h>
|
|
#include <mysqlxx/PoolWithFailover.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
/** Implements storage in the MySQL database.
|
|
* Use ENGINE = mysql(host_port, database_name, table_name, user_name, password)
|
|
* Read only.
|
|
*/
|
|
class StorageMySQL final : public ext::shared_ptr_helper<StorageMySQL>, public IStorage, WithContext
|
|
{
|
|
friend struct ext::shared_ptr_helper<StorageMySQL>;
|
|
public:
|
|
StorageMySQL(
|
|
const StorageID & table_id_,
|
|
mysqlxx::PoolWithFailover && pool_,
|
|
const std::string & remote_database_name_,
|
|
const std::string & remote_table_name_,
|
|
bool replace_query_,
|
|
const std::string & on_duplicate_clause_,
|
|
const ColumnsDescription & columns_,
|
|
const ConstraintsDescription & constraints_,
|
|
const String & comment,
|
|
ContextPtr context_,
|
|
const MySQLSettings & mysql_settings_);
|
|
|
|
std::string getName() const override { return "MySQL"; }
|
|
|
|
Pipe read(
|
|
const Names & column_names,
|
|
const StorageMetadataPtr & /*metadata_snapshot*/,
|
|
SelectQueryInfo & query_info,
|
|
ContextPtr context,
|
|
QueryProcessingStage::Enum processed_stage,
|
|
size_t max_block_size,
|
|
unsigned num_streams) override;
|
|
|
|
BlockOutputStreamPtr write(const ASTPtr & query, const StorageMetadataPtr & /*metadata_snapshot*/, ContextPtr context) override;
|
|
|
|
private:
|
|
friend class StorageMySQLBlockOutputStream;
|
|
|
|
std::string remote_database_name;
|
|
std::string remote_table_name;
|
|
bool replace_query;
|
|
std::string on_duplicate_clause;
|
|
|
|
MySQLSettings mysql_settings;
|
|
|
|
mysqlxx::PoolWithFailoverPtr pool;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|