diff --git a/cql3/query_processor.cc b/cql3/query_processor.cc index 78a2c5930d..6564af4164 100644 --- a/cql3/query_processor.cc +++ b/cql3/query_processor.cc @@ -413,21 +413,16 @@ query_processor::query_processor(service::storage_proxy& proxy, database& db, se _cql_stats.select_allow_filtering, sm::description("Counts the number of SELECT query executions with ALLOW FILTERING option.")), - sm::make_derive( - "select_full_scan", - _cql_stats.select_full_scan, - sm::description("Counts the number of SELECT query executions requiring full scan.")), - - sm::make_derive( - "select_full_scan_no_bypass_cache", - _cql_stats.select_full_scan_no_bypass_cache, - sm::description("Counts the number of SELECT query executions requiring full scan without BYPASS CACHE option.")), - sm::make_derive( "select_partition_range_scan", _cql_stats.select_partition_range_scan, sm::description("Counts the number of SELECT query executions requiring partition range scan.")), + sm::make_derive( + "select_partition_range_scan_no_bypass_cache", + _cql_stats.select_partition_range_scan_no_bypass_cache, + sm::description("Counts the number of SELECT query executions requiring partition range scan without BYPASS CACHE option.")), + sm::make_derive( "authorized_prepared_statements_cache_evictions", [] { return authorized_prepared_statements_cache::shard_stats().authorized_prepared_statements_cache_evictions; }, diff --git a/cql3/statements/select_statement.cc b/cql3/statements/select_statement.cc index da452f6fe4..1d294b7dfd 100644 --- a/cql3/statements/select_statement.cc +++ b/cql3/statements/select_statement.cc @@ -316,9 +316,8 @@ select_statement::do_execute(service::storage_proxy& proxy, _stats.select_bypass_caches += _parameters->bypass_cache(); _stats.select_allow_filtering += _parameters->allow_filtering(); - _stats.select_full_scan += _full_scan; - _stats.select_full_scan_no_bypass_cache += _full_scan_no_bypass_cache; _stats.select_partition_range_scan += _range_scan; + _stats.select_partition_range_scan_no_bypass_cache += _range_scan_no_bypass_cache; auto command = ::make_lw_shared(_schema->id(), _schema->version(), make_partition_slice(options), limit, now, tracing::make_trace_info(state.get_trace_state()), query::max_partitions, utils::UUID(), options.get_timestamp(state)); @@ -734,14 +733,12 @@ primary_key_select_statement::primary_key_select_statement(schema_ptr schema, ui { if (_ks_sel == ks_selector::NONSYSTEM) { if (_restrictions->need_filtering() || - _restrictions->get_partition_key_restrictions()->empty()) { - _full_scan = true; // Filtered (unindexed) or unrestricted PK + _restrictions->get_partition_key_restrictions()->empty() || + (_restrictions->get_partition_key_restrictions()->is_on_token() && + !_restrictions->get_partition_key_restrictions()->is_EQ())) { + _range_scan = true; if (!_parameters->bypass_cache()) - _full_scan_no_bypass_cache = true; - } else { - if (_restrictions->get_partition_key_restrictions()->is_on_token() && - !_restrictions->get_partition_key_restrictions()->is_EQ()) - _range_scan = true; // Token range + _range_scan_no_bypass_cache = true; } } } diff --git a/cql3/statements/select_statement.hh b/cql3/statements/select_statement.hh index 54583e7809..7571437b5d 100644 --- a/cql3/statements/select_statement.hh +++ b/cql3/statements/select_statement.hh @@ -94,9 +94,8 @@ protected: query::partition_slice::option_set _opts; cql_stats& _stats; const ks_selector _ks_sel; - bool _full_scan = false; - bool _full_scan_no_bypass_cache = false; bool _range_scan = false; + bool _range_scan_no_bypass_cache = false; protected : virtual future<::shared_ptr> do_execute(service::storage_proxy& proxy, service::query_state& state, const query_options& options) const; diff --git a/cql3/stats.hh b/cql3/stats.hh index 90fafe626c..36453c2c5b 100644 --- a/cql3/stats.hh +++ b/cql3/stats.hh @@ -87,9 +87,8 @@ struct cql_stats { int64_t select_bypass_caches = 0; int64_t select_allow_filtering = 0; - int64_t select_full_scan = 0; - int64_t select_full_scan_no_bypass_cache = 0; int64_t select_partition_range_scan = 0; + int64_t select_partition_range_scan_no_bypass_cache = 0; private: uint64_t _unpaged_select_queries[(size_t)ks_selector::SIZE] = {0ul}; diff --git a/test/boost/query_processor_test.cc b/test/boost/query_processor_test.cc index 3dd396d95b..884bbeabef 100644 --- a/test/boost/query_processor_test.cc +++ b/test/boost/query_processor_test.cc @@ -319,50 +319,50 @@ SEASTAR_TEST_CASE(test_select_full_scan_metrics) { BOOST_CHECK_EQUAL(stat_ac1 + 1, qp.get_cql_stats().select_allow_filtering); // Unrestricted PK, full scan without BYPASS CACHE - auto stat_fs1 = qp.get_cql_stats().select_full_scan; - auto stat_fsnb1 = qp.get_cql_stats().select_full_scan_no_bypass_cache; + auto stat_ps1 = qp.get_cql_stats().select_partition_range_scan; + auto stat_psnb1 = qp.get_cql_stats().select_partition_range_scan_no_bypass_cache; qp.execute_internal("select * from ks.fsm;").get(); - BOOST_CHECK_EQUAL(stat_fs1 + 1, qp.get_cql_stats().select_full_scan); - BOOST_CHECK_EQUAL(stat_fsnb1 + 1, qp.get_cql_stats().select_full_scan_no_bypass_cache); + BOOST_CHECK_EQUAL(stat_ps1 + 1, qp.get_cql_stats().select_partition_range_scan); + BOOST_CHECK_EQUAL(stat_psnb1 + 1, qp.get_cql_stats().select_partition_range_scan_no_bypass_cache); // Unrestricted PK, full scan with BYPASS CACHE - auto stat_fsnb2 = qp.get_cql_stats().select_full_scan_no_bypass_cache; + auto stat_psnb2 = qp.get_cql_stats().select_partition_range_scan_no_bypass_cache; qp.execute_internal("select * from ks.fsm BYPASS CACHE;").get(); - BOOST_CHECK_EQUAL(stat_fsnb2, qp.get_cql_stats().select_full_scan_no_bypass_cache); + BOOST_CHECK_EQUAL(stat_psnb2, qp.get_cql_stats().select_partition_range_scan_no_bypass_cache); // Restricted PK, no full scan - auto stat_fs2 = qp.get_cql_stats().select_full_scan; + auto stat_ps2 = qp.get_cql_stats().select_partition_range_scan; qp.execute_internal("select * from ks.fsm where pk = 1;").get(); - BOOST_CHECK_EQUAL(stat_fs2, qp.get_cql_stats().select_full_scan); + BOOST_CHECK_EQUAL(stat_ps2, qp.get_cql_stats().select_partition_range_scan); // Indexed on c1, no full scan - auto stat_fs3 = qp.get_cql_stats().select_full_scan; + auto stat_ps3 = qp.get_cql_stats().select_partition_range_scan; qp.execute_internal("select * from ks.fsm where c1 = 1;").get(); - BOOST_CHECK_EQUAL(stat_fs3, qp.get_cql_stats().select_full_scan); + BOOST_CHECK_EQUAL(stat_ps3, qp.get_cql_stats().select_partition_range_scan); // Filtered by ck but not filtered by pk - auto stat_fs4 = qp.get_cql_stats().select_full_scan; + auto stat_ps4 = qp.get_cql_stats().select_partition_range_scan; qp.execute_internal("select * from ks.fsm where ck = 1 allow filtering;").get(); - BOOST_CHECK_EQUAL(stat_fs4 + 1, qp.get_cql_stats().select_full_scan); + BOOST_CHECK_EQUAL(stat_ps4 + 1, qp.get_cql_stats().select_partition_range_scan); // Filtered by unindexed non-cluster column - auto stat_fs5 = qp.get_cql_stats().select_full_scan; + auto stat_ps5 = qp.get_cql_stats().select_partition_range_scan; qp.execute_internal("select * from ks.fsm where c2 = 1 allow filtering;").get(); - BOOST_CHECK_EQUAL(stat_fs5 + 1, qp.get_cql_stats().select_full_scan); + BOOST_CHECK_EQUAL(stat_ps5 + 1, qp.get_cql_stats().select_partition_range_scan); // System table full scan, not measured - auto stat_fs6 = qp.get_cql_stats().select_full_scan; + auto stat_ps6 = qp.get_cql_stats().select_partition_range_scan; qp.execute_internal("select * from system.views_builds_in_progress;").get(); - BOOST_CHECK_EQUAL(stat_fs6, qp.get_cql_stats().select_full_scan); + BOOST_CHECK_EQUAL(stat_ps6, qp.get_cql_stats().select_partition_range_scan); // Range token on PK, full scan - auto stat_rs1 = qp.get_cql_stats().select_partition_range_scan; + auto stat_ps7 = qp.get_cql_stats().select_partition_range_scan; qp.execute_internal("select * from ks.fsm where token(pk) > 100;").get(); - BOOST_CHECK_EQUAL(stat_rs1 + 1, qp.get_cql_stats().select_partition_range_scan); + BOOST_CHECK_EQUAL(stat_ps7 + 1, qp.get_cql_stats().select_partition_range_scan); // Token on PK equals, no full scan - auto stat_rs2 = qp.get_cql_stats().select_partition_range_scan; + auto stat_ps8 = qp.get_cql_stats().select_partition_range_scan; qp.execute_internal("select * from ks.fsm where token(pk) = 1;").get(); - BOOST_CHECK_EQUAL(stat_rs2, qp.get_cql_stats().select_partition_range_scan); + BOOST_CHECK_EQUAL(stat_ps8, qp.get_cql_stats().select_partition_range_scan); }); }