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
3486bf41
Commit
3486bf41
authored
Aug 31, 2021
by
Sergei Petrunia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup + reduce the diff size
parent
229c836d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
37 deletions
+27
-37
sql/sql_statistics.cc
sql/sql_statistics.cc
+5
-15
sql/sql_statistics.h
sql/sql_statistics.h
+22
-22
No files found.
sql/sql_statistics.cc
View file @
3486bf41
...
...
@@ -3620,16 +3620,6 @@ int read_histograms_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables)
if
(
stats_cb
->
start_histograms_load
())
{
//uchar *histogram= (uchar *) alloc_root(&stats_cb->mem_root,
// stats_cb->total_hist_size);
/*
if (!histogram)
{
stats_cb->abort_histograms_load();
DBUG_RETURN(1);
}
*/
Column_stat
column_stat
(
stat_tables
[
COLUMN_STAT
].
table
,
table
);
for
(
Field
**
field_ptr
=
table
->
s
->
field
;
*
field_ptr
;
field_ptr
++
)
{
...
...
@@ -4393,10 +4383,9 @@ double get_column_range_cardinality(Field *field,
/*
Estimate selectivity of "col=const" using a histogram
@param field
-
the field to estimate its selectivity.
@param field
the field to estimate its selectivity.
@param min_endp, max_endp - Specifies the left and right bounds. For point selectivity,
they are both equal.
@param endpoint The constant
@param avg_sel Average selectivity of condition "col=const" in this table.
It is calcuated as (#non_null_values / #distinct_values).
...
...
@@ -4426,11 +4415,12 @@ double get_column_range_cardinality(Field *field,
value.
*/
double
Histogram_binary
::
point_selectivity
(
Field
*
field
,
key_range
*
min_endp
,
double
avg_sel
)
double
Histogram_binary
::
point_selectivity
(
Field
*
field
,
key_range
*
endpoint
,
double
avg_sel
)
{
double
sel
;
Column_statistics
*
col_stats
=
field
->
read_stats
;
store_key_image_to_rec
(
field
,
(
uchar
*
)
min_endp
->
key
,
store_key_image_to_rec
(
field
,
(
uchar
*
)
endpoint
->
key
,
field
->
key_length
());
double
pos
=
field
->
pos_in_interval
(
col_stats
->
min_value
,
col_stats
->
max_value
);
...
...
sql/sql_statistics.h
View file @
3486bf41
...
...
@@ -195,26 +195,6 @@ class Histogram_base : public Sql_alloc
class
Histogram_binary
:
public
Histogram_base
{
public:
bool
parse
(
MEM_ROOT
*
mem_root
,
Field
*
,
Histogram_type
type_arg
,
const
char
*
hist_data
,
size_t
hist_data_len
)
override
;
void
serialize
(
Field
*
to_field
)
override
;
Histogram_type
get_type
()
override
{
return
type
;
}
uint
get_width
()
override
{
switch
(
type
)
{
case
SINGLE_PREC_HB
:
return
size
;
case
DOUBLE_PREC_HB
:
return
size
/
2
;
default:
DBUG_ASSERT
(
0
);
}
return
0
;
}
private:
Histogram_type
type
;
uint8
size
;
/* Size of values array, in bytes */
...
...
@@ -233,6 +213,20 @@ class Histogram_binary : public Histogram_base
return
1
;
}
public:
uint
get_width
()
override
{
switch
(
type
)
{
case
SINGLE_PREC_HB
:
return
size
;
case
DOUBLE_PREC_HB
:
return
size
/
2
;
default:
DBUG_ASSERT
(
0
);
}
return
0
;
}
private:
uint
get_value
(
uint
i
)
{
DBUG_ASSERT
(
i
<
get_width
());
...
...
@@ -287,10 +281,16 @@ class Histogram_binary : public Histogram_base
}
public:
void
init_for_collection
(
MEM_ROOT
*
mem_root
,
Histogram_type
htype_arg
,
ulonglong
size
)
override
;
uint
get_size
()
override
{
return
(
uint
)
size
;}
Histogram_type
get_type
()
override
{
return
type
;
}
bool
parse
(
MEM_ROOT
*
mem_root
,
Field
*
,
Histogram_type
type_arg
,
const
char
*
hist_data
,
size_t
hist_data_len
)
override
;
void
serialize
(
Field
*
to_field
)
override
;
void
init_for_collection
(
MEM_ROOT
*
mem_root
,
Histogram_type
htype_arg
,
ulonglong
size
)
override
;
bool
is_available
()
override
{
return
(
values
!=
NULL
);
}
/*
...
...
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