Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
3692adeb
Commit
3692adeb
authored
Aug 22, 2021
by
Michael Okoko
Committed by
Sergei Petrunia
Jan 19, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix avg_frequency statistics and remove stderr dumps
Signed-off-by:
Michael Okoko
<
okokomichaels@outlook.com
>
parent
bff65a81
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
20 deletions
+14
-20
mysql-test/main/statistics_json.result
mysql-test/main/statistics_json.result
+2
-2
sql/sql_statistics.cc
sql/sql_statistics.cc
+12
-18
No files found.
mysql-test/main/statistics_json.result
View file @
3692adeb
...
...
@@ -164,12 +164,12 @@ id select_type table type possible_keys key key_len ref rows r_rows filtered r_f
1 SIMPLE users ALL NULL NULL NULL NULL 101 101.00 98.04 98.02 Using where
explain extended select * from users where city = 'Helsinki';
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE users ALL NULL NULL NULL NULL 101
50
.00 Using where
1 SIMPLE users ALL NULL NULL NULL NULL 101
2
.00 Using where
Warnings:
Note 1003 select `test`.`users`.`city` AS `city` from `test`.`users` where `test`.`users`.`city` = 'Helsinki'
analyze select * from users where city = 'helsinki';
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE users ALL NULL NULL NULL NULL 101 101.00
50
.00 1.98 Using where
1 SIMPLE users ALL NULL NULL NULL NULL 101 101.00
2
.00 1.98 Using where
drop table t1_bin;
drop table t1_json;
drop table users;
...
...
sql/sql_statistics.cc
View file @
3692adeb
...
...
@@ -1470,8 +1470,6 @@ double Histogram_json::point_selectivity(Field *field, key_range *endpoint, doub
max_idx
++
;
}
//todo: do we need to account for zero value-length similarly to binary histograms.
if
(
max_idx
>
min_idx
)
{
// value spans multiple buckets
...
...
@@ -1480,7 +1478,7 @@ double Histogram_json::point_selectivity(Field *field, key_range *endpoint, doub
}
else
{
// the value fits within a single bucket
sel
=
M
IN
(
avg_sel
,
get_width
(
));
sel
=
M
Y_MIN
(
avg_sel
,
(
1.0
/
get_width
()
));
}
return
sel
;
}
...
...
@@ -1494,7 +1492,7 @@ double Histogram_json::point_selectivity(Field *field, key_range *endpoint, doub
double
Histogram_json
::
range_selectivity
(
Field
*
field
,
key_range
*
min_endp
,
key_range
*
max_endp
)
{
fprintf
(
stderr
,
"Histogram_json::range_selectivity
\n
"
);
//
fprintf(stderr, "Histogram_json::range_selectivity\n");
double
min
=
0.0
,
max
=
1.0
;
double
width
=
1.0
/
(
int
)
histogram_bounds
.
size
();
if
(
min_endp
)
...
...
@@ -1529,8 +1527,8 @@ double Histogram_json::range_selectivity(Field *field, key_range *min_endp,
}
min
=
min_bucket_idx
*
(
width
)
+
min_sel
*
(
width
);
fprintf
(
stderr
,
"min pos_in_interval =%g
\n
"
,
min_sel
);
fprintf
(
stderr
,
"min =%g
\n
"
,
min
);
//
fprintf(stderr, "min pos_in_interval =%g\n", min_sel);
//
fprintf(stderr, "min =%g\n", min);
}
if
(
max_endp
)
{
...
...
@@ -1562,13 +1560,13 @@ double Histogram_json::range_selectivity(Field *field, key_range *min_endp,
}
max
=
min_bucket_idx
*
(
width
)
+
max_sel
*
(
width
);
fprintf
(
stderr
,
"max pos_in_interval =%g
\n
"
,
max_sel
);
fprintf
(
stderr
,
"max =%g
\n
"
,
max
);
//
fprintf(stderr, "max pos_in_interval =%g\n", max_sel);
//
fprintf(stderr, "max =%g\n", max);
}
double
sel
=
max
-
min
;
fprintf
(
stderr
,
"final selection = %g
\n
"
,
sel
);
fprintf
(
stderr
,
"Histogram_json::range_selectivity ends
\n
"
);
//
fprintf(stderr, "final selection = %g\n", sel);
//
fprintf(stderr, "Histogram_json::range_selectivity ends\n");
return
sel
;
}
...
...
@@ -4504,7 +4502,6 @@ double Histogram_binary::range_selectivity(Field *field,
key_range
*
min_endp
,
key_range
*
max_endp
)
{
fprintf
(
stderr
,
"Histogram_binary::range_selectivity
\n
"
);
double
sel
,
min_mp_pos
,
max_mp_pos
;
Column_statistics
*
col_stats
=
field
->
read_stats
;
...
...
@@ -4527,8 +4524,6 @@ double Histogram_binary::range_selectivity(Field *field,
else
max_mp_pos
=
1.0
;
// GSOC-todo: previously it was if (hist && hist->is_usable) - I wonder in what cases
// (hist) would be null and if it makes sense to handle that case now.
if
(
is_usable
(
field
->
table
->
in_use
))
{
double
bucket_sel
=
1.0
/
(
get_width
()
+
1
);
...
...
@@ -4536,19 +4531,18 @@ double Histogram_binary::range_selectivity(Field *field,
uint
max
=
find_bucket
(
max_mp_pos
,
FALSE
);
sel
=
bucket_sel
*
(
max
-
min
+
1
);
fprintf
(
stderr
,
"bucket_sel =%g
\n
"
,
bucket_sel
);
/*
fprintf(stderr, "bucket_sel =%g\n", bucket_sel);
fprintf(stderr, "min pos_in_interval =%g\n", min_mp_pos);
fprintf(stderr, "max pos_in_interval =%g\n", max_mp_pos);
fprintf(stderr, "min =%d\n", min);
fprintf
(
stderr
,
"max =%d
\n
"
,
max
);
fprintf(stderr, "max =%d\n", max);
*/
}
else
{
/* GSOC-todo: figure how to handle the else case below for Histogram_json*/
sel
=
(
max_mp_pos
-
min_mp_pos
);
}
fprintf
(
stderr
,
"final sel =%g
\n
"
,
sel
);
fprintf
(
stderr
,
"Histogram_binary::range_selectivity ends
\n
"
);
/*
fprintf(stderr, "final sel =%g\n", sel);
fprintf(stderr, "Histogram_binary::range_selectivity ends\n");
*/
return
sel
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment