mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-23 01:50:35 +00:00
cql3: statement_restrictions: use pre-built single-column maps for index support checks
Replace index_supports_some_column(expression, ...) with index_supports_some_column(single_column_restrictions_map, ...) to eliminate get_single_column_restrictions_map() tree walks when checking index support. The three call sites now use the maps already built incrementally in the constructor loop: _single_column_nonprimary_key_restrictions, _single_column_clustering_key_restrictions, and _single_column_partition_key_restrictions. Also replace contains_multi_column_restriction() tree walk in clustering_columns_restrictions_have_supporting_index() with _has_multi_column.
This commit is contained in:
@@ -71,9 +71,8 @@ extern bool has_supporting_index(
|
||||
const expression&, const secondary_index::secondary_index_manager&, allow_local_index allow_local);
|
||||
|
||||
// Looks at each column individually and checks whether some index can support restrictions on this single column.
|
||||
// Expression has to consist only of single column restrictions.
|
||||
extern bool index_supports_some_column(
|
||||
const expression&,
|
||||
const single_column_restrictions_map&,
|
||||
const secondary_index::secondary_index_manager&,
|
||||
allow_local_index allow_local);
|
||||
|
||||
@@ -786,11 +785,9 @@ bool has_supporting_index(
|
||||
}
|
||||
|
||||
bool index_supports_some_column(
|
||||
const expression& e,
|
||||
const single_column_restrictions_map& single_col_restrictions,
|
||||
const secondary_index::secondary_index_manager& index_manager,
|
||||
allow_local_index allow_local) {
|
||||
single_column_restrictions_map single_col_restrictions = get_single_column_restrictions_map(e);
|
||||
|
||||
for (auto&& [col, col_restrictions] : single_col_restrictions) {
|
||||
if (has_supporting_index(col_restrictions, index_manager, allow_local)) {
|
||||
return true;
|
||||
@@ -1296,7 +1293,7 @@ statement_restrictions::statement_restrictions(private_tag,
|
||||
&& !type.is_delete();
|
||||
_has_queriable_pk_index = parition_key_restrictions_have_supporting_index(sim, allow_local)
|
||||
&& !type.is_delete();
|
||||
_has_queriable_regular_index = index_supports_some_column(_nonprimary_key_restrictions, sim, allow_local)
|
||||
_has_queriable_regular_index = index_supports_some_column(_single_column_nonprimary_key_restrictions, sim, allow_local)
|
||||
&& !type.is_delete();
|
||||
} else {
|
||||
_has_queriable_ck_index = false;
|
||||
@@ -1727,8 +1724,8 @@ bool statement_restrictions::clustering_columns_restrictions_have_supporting_ind
|
||||
const secondary_index::secondary_index_manager& index_manager,
|
||||
expr::allow_local_index allow_local) const {
|
||||
// Single column restrictions can be handled by the existing code
|
||||
if (!contains_multi_column_restriction(_clustering_columns_restrictions)) {
|
||||
return index_supports_some_column(_clustering_columns_restrictions, index_manager, allow_local);
|
||||
if (!_has_multi_column) {
|
||||
return index_supports_some_column(_single_column_clustering_key_restrictions, index_manager, allow_local);
|
||||
}
|
||||
|
||||
// Multi column restrictions have to be handled separately
|
||||
@@ -1805,7 +1802,7 @@ bool statement_restrictions::parition_key_restrictions_have_supporting_index(con
|
||||
return false;
|
||||
}
|
||||
|
||||
return index_supports_some_column(_partition_key_restrictions, index_manager, allow_local);
|
||||
return index_supports_some_column(_single_column_partition_key_restrictions, index_manager, allow_local);
|
||||
}
|
||||
|
||||
void statement_restrictions::process_clustering_columns_restrictions(bool for_view, bool allow_filtering) {
|
||||
|
||||
Reference in New Issue
Block a user