2019-12-10 23:18:24 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Core/SortDescription.h>
|
|
|
|
#include <Storages/MergeTree/MergeTreeData.h>
|
|
|
|
#include <Storages/SelectQueryInfo.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/** Helper class, that can analyze MergeTree order key
|
2019-12-20 13:15:17 +00:00
|
|
|
* and required sort description to get their
|
|
|
|
* common prefix, which is needed for
|
2019-12-10 23:18:24 +00:00
|
|
|
* performing reading in order of PK.
|
|
|
|
*/
|
|
|
|
class ReadInOrderOptimizer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ReadInOrderOptimizer(
|
|
|
|
const ManyExpressionActions & elements_actions,
|
|
|
|
const SortDescription & required_sort_description,
|
2020-07-22 17:13:05 +00:00
|
|
|
const TreeRewriterResultPtr & syntax_result);
|
2019-12-10 23:18:24 +00:00
|
|
|
|
2020-06-17 11:05:11 +00:00
|
|
|
InputOrderInfoPtr getInputOrder(const StoragePtr & storage, const StorageMetadataPtr & metadata_snapshot) const;
|
2019-12-10 23:18:24 +00:00
|
|
|
|
|
|
|
private:
|
2020-02-14 07:12:04 +00:00
|
|
|
/// Actions for every element of order expression to analyze functions for monotonicity
|
2019-12-10 23:18:24 +00:00
|
|
|
ManyExpressionActions elements_actions;
|
|
|
|
NameSet forbidden_columns;
|
2019-12-11 01:34:39 +00:00
|
|
|
SortDescription required_sort_description;
|
2019-12-10 23:18:24 +00:00
|
|
|
};
|
|
|
|
|
2020-02-14 13:31:01 +00:00
|
|
|
}
|