From 3916bf116894705b6375cd2e6b31889cbed8cfd5 Mon Sep 17 00:00:00 2001 From: Jan Ciolek Date: Tue, 28 Jun 2022 08:09:51 +0200 Subject: [PATCH] cql3: Keep single column restrictions map inside statement restrictions Some parts of the code make use of a map keeping single column restrictions for each partition key column. One of this places is inside do_filter, so it could be a performance problem to create such a map from scratch each time. After adding all restrictions from the where clause the new map is created and can be used for various purposes. Signed-off-by: Jan Ciolek --- cql3/restrictions/statement_restrictions.cc | 3 +++ cql3/restrictions/statement_restrictions.hh | 2 ++ 2 files changed, 5 insertions(+) diff --git a/cql3/restrictions/statement_restrictions.cc b/cql3/restrictions/statement_restrictions.cc index c2c44b6ca3..d1a4a6b0ce 100644 --- a/cql3/restrictions/statement_restrictions.cc +++ b/cql3/restrictions/statement_restrictions.cc @@ -470,6 +470,9 @@ statement_restrictions::statement_restrictions(data_dictionary::database db, } } if (_where.has_value()) { + if (!has_token(_new_partition_key_restrictions)) { + _single_column_partition_key_restrictions = expr::get_single_column_restrictions_map(_new_partition_key_restrictions); + } _clustering_prefix_restrictions = extract_clustering_prefix_restrictions(*_where, _schema); _partition_range_restrictions = extract_partition_range(*_where, _schema); } diff --git a/cql3/restrictions/statement_restrictions.hh b/cql3/restrictions/statement_restrictions.hh index 2e70f89a1b..26f91670e7 100644 --- a/cql3/restrictions/statement_restrictions.hh +++ b/cql3/restrictions/statement_restrictions.hh @@ -46,6 +46,8 @@ private: expr::expression _new_partition_key_restrictions; + expr::single_column_restrictions_map _single_column_partition_key_restrictions; + /** * Restrictions on clustering columns */