ClickHouse/base/mysqlxx/mysqlxx.h

59 lines
2.7 KiB
C++
Raw Normal View History

2014-04-08 06:51:53 +00:00
#pragma once
2011-03-03 19:57:34 +00:00
#include <mysqlxx/Connection.h>
2011-03-04 20:58:19 +00:00
#include <mysqlxx/Transaction.h>
#include <mysqlxx/Pool.h>
2021-10-02 07:13:14 +00:00
#include <base/LocalDate.h>
#include <base/LocalDateTime.h>
2011-03-09 19:18:01 +00:00
#include <mysqlxx/Null.h>
2011-03-03 19:57:34 +00:00
2011-03-18 20:26:54 +00:00
2017-07-27 19:58:25 +00:00
/** 'mysqlxx' - very simple library for replacement of 'mysql++' library.
*
* For whatever reason, in Yandex.Metrica, back in 2008, 'mysql++' library was used.
* There are the following shortcomings of 'mysql++':
* 1. Too rich functionality: most of it is not used.
* 2. Low performance (when used for Yandex.Metrica).
*
* Low performance is caused by the following reasons:
*
* 1. Excessive copying: 'mysqlpp::Row' works like 'std::vector<std::string>'.
* Content of MYSQL_ROW is copied inside it.
* But MYSQL_ROW is a 'char**', that is allocated in single piece,
* where values are stored consecutively as (non-zero-terminated) strings.
*
* 2. Too slow methods for converting values to numbers.
* In mysql++, it is done through std::stringstream.
* This is slower than POSIX functions (strtoul, etc).
* In turn, this is slower than simple hand-coded functions,
* that doesn't respect locales and unused by MySQL number representations.
*
* 3. Too slow methods of escaping and quoting.
* In mysql++, 'mysql_real_escape_string' is used, that works correct
* even for charsets, that are not based on ASCII (examples: UTF-16, Shift-JIS).
* But when using charsets based on ASCII, as UTF-8,
* (in general, charsets, where escape characters are represented in same way as in ASCII,
* and where that codes cannot appear in representation of another characters)
* this function is redundant.
*
* 4. Too much garbage (dynamic_cast, typeid when converting values).
*
* Low performance cause the following effects:
* 1. In sequential read from MySQL table, the client CPU becomes a bottleneck, while MySQL server is not loaded.
* When using bare MySQL C API, this doesn't happen.
* 2. Sequential read from MySQL is lower than 30MB/s.
*
* Warning!
*
* mysqlxx is implemented as very simple wrapper around MySQL C API,
* and implements only limited subset of mysql++ interface, that we use.
* And for the sake of simplicity, some functions work only with certain assumptions,
* or with slightly different semantic than in mysql++.
* And we don't care about cross-platform usage of mysqlxx.
* These assumptions are specific for Yandex.Metrica. Your mileage may vary.
*
* mysqlxx could not be considered as separate full-featured library,
2020-08-08 01:21:04 +00:00
* because it is developed from the principle - "everything that we don't need is not implemented".
2017-07-27 19:58:25 +00:00
* It is assumed that the user will add all missing functionality that is needed.
2011-03-03 19:57:34 +00:00
*/