Kouhei Sutou 2019-03-04 13:07:45 +0900 (Mon, 04 Mar 2019) Revision: 7788a4a7e6753086dd97a5cd5f85d8112fb41736 https://github.com/groonga/groonga/commit/7788a4a7e6753086dd97a5cd5f85d8112fb41736 Message: expr optimize: add support for estimation for prefix Modified files: lib/mrb/scripts/expression_tree/binary_operation.rb Modified: lib/mrb/scripts/expression_tree/binary_operation.rb (+14 -0) =================================================================== --- lib/mrb/scripts/expression_tree/binary_operation.rb 2019-03-04 13:07:38 +0900 (bf4d05257) +++ lib/mrb/scripts/expression_tree/binary_operation.rb 2019-03-04 13:07:45 +0900 (bceece427) @@ -45,6 +45,8 @@ module Groonga estimate_size_range(table) when *QUERY_OPERATIONS estimate_size_query(table) + when Operator::PREFIX + estimate_size_prefix(table) else table.size end @@ -119,6 +121,18 @@ module Groonga end sizes.max end + + def estimate_size_prefix(table) + return table.size unles****@left*****_a?(Variable) + return table.size unles****@right*****_a?(Constant) + + key =****@left***** + return table.size unless key.is_a?(Groonga::Accessor) + return table.size unless key.key? + + # TODO: Improve + table.size / 10 + end end end end -------------- next part -------------- An HTML attachment was scrubbed... URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190304/f03aa54c/attachment-0001.html>