ClickHouse/docs/en/table_engines/replacingmergetree.rst

20 lines
1.1 KiB
ReStructuredText
Raw Normal View History

2017-04-03 19:49:50 +00:00
ReplacingMergeTree
------------------
2017-04-26 17:26:17 +00:00
This engine differs from ``MergeTree`` in that it can deduplicate data by primary key while merging.
2017-04-03 19:49:50 +00:00
2017-04-26 17:26:17 +00:00
For ReplacingMergeTree mode, last parameter is optional name of 'version' column. While merging, for all rows with same primary key, only one row is selected: last row, if version column was not specified, or last row with maximum version value, if specified.
2017-04-03 19:49:50 +00:00
2017-04-26 17:26:17 +00:00
Version column must have type of UInt family or ``Date`` or ``DateTime``.
2017-04-03 19:49:50 +00:00
.. code-block:: sql
ReplacingMergeTree(EventDate, (OrderID, EventDate, BannerID, ...), 8192, ver)
2017-04-26 17:26:17 +00:00
Please note, that data is deduplicated only while merging process. Merges are processed in background. Exact time of merge is unspecified and you could not rely on it. Some part of data could be not merged at all. While you could trigger extra merge with OPTIMIZE query, it is not recommended, as OPTIMIZE will read and write vast amount of data.
2017-04-03 19:49:50 +00:00
2017-04-26 17:26:17 +00:00
This table engine is suitable for background removal of duplicate data to save space, but not suitable to guarantee of deduplication.
*Developed for special purposes of not Yandex.Metrica department.*
2017-04-03 19:49:50 +00:00