summaryrefslogtreecommitdiff
path: root/sql/table.cc
diff options
context:
space:
mode:
authorVarun Gupta <varunraiko1803@gmail.com>2018-06-09 11:26:52 +0530
committerVarun Gupta <varunraiko1803@gmail.com>2018-06-09 11:40:28 +0530
commitcd33280b682692f0517a26178d7b5337db648751 (patch)
treec1f44cf1e5ba5f52809a84e39c353a4fe2035428 /sql/table.cc
parent15155ecd3483c47d8f2c05727184f6bf47bbf0b0 (diff)
downloadmariadb-git-cd33280b682692f0517a26178d7b5337db648751.tar.gz
MDEV-16374: Filtered shows 0 for materilization scan for a semi join, which makes optimizer always picks
materialization scan over materialization lookup For non-mergeable semi-joins we don't store the estimates of the IN subquery in table->file->stats.records. In the function TABLE_LIST::fetch_number_of_rows, we store the number of rows in the tables (estimates in case of derived table/views). Currently we don't store the estimates for non-mergeable semi-joins, which leads to a problem of selecting materialization scan over materialization lookup. Fixed this by storing these estimated appropriately
Diffstat (limited to 'sql/table.cc')
-rw-r--r--sql/table.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/sql/table.cc b/sql/table.cc
index bc6e1e754ee..b5082df7076 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -7099,7 +7099,15 @@ int TABLE_LIST::fetch_number_of_rows()
{
int error= 0;
if (jtbm_subselect)
+ {
+ if (jtbm_subselect->is_jtbm_merged)
+ {
+ table->file->stats.records= jtbm_subselect->jtbm_record_count;
+ set_if_bigger(table->file->stats.records, 2);
+ table->used_stat_records= table->file->stats.records;
+ }
return 0;
+ }
if (is_materialized_derived() && !fill_me)
{