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
695ce3ad
Commit
695ce3ad
authored
Nov 08, 2014
by
Rich Prohaska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DB-756 set cardinality data for partitioned tokudb tables
parent
10532d81
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
195 additions
and
24 deletions
+195
-24
mysql-test/suite/tokudb.bugs/r/db756_card_part_hash.result
mysql-test/suite/tokudb.bugs/r/db756_card_part_hash.result
+21
-0
mysql-test/suite/tokudb.bugs/r/db756_card_part_hash_1.result
mysql-test/suite/tokudb.bugs/r/db756_card_part_hash_1.result
+20
-0
mysql-test/suite/tokudb.bugs/r/db756_card_part_hash_1_pick.result
...st/suite/tokudb.bugs/r/db756_card_part_hash_1_pick.result
+21
-0
mysql-test/suite/tokudb.bugs/r/db756_card_part_hash_2.result
mysql-test/suite/tokudb.bugs/r/db756_card_part_hash_2.result
+20
-0
mysql-test/suite/tokudb.bugs/r/db756_card_part_hash_2_pick.result
...st/suite/tokudb.bugs/r/db756_card_part_hash_2_pick.result
+21
-0
mysql-test/suite/tokudb.bugs/t/db756_card_part_hash.test
mysql-test/suite/tokudb.bugs/t/db756_card_part_hash.test
+15
-0
mysql-test/suite/tokudb.bugs/t/db756_card_part_hash_1.test
mysql-test/suite/tokudb.bugs/t/db756_card_part_hash_1.test
+14
-0
mysql-test/suite/tokudb.bugs/t/db756_card_part_hash_1_pick.test
...test/suite/tokudb.bugs/t/db756_card_part_hash_1_pick.test
+15
-0
mysql-test/suite/tokudb.bugs/t/db756_card_part_hash_2.test
mysql-test/suite/tokudb.bugs/t/db756_card_part_hash_2.test
+14
-0
mysql-test/suite/tokudb.bugs/t/db756_card_part_hash_2_pick.test
...test/suite/tokudb.bugs/t/db756_card_part_hash_2_pick.test
+15
-0
storage/tokudb/ha_tokudb.cc
storage/tokudb/ha_tokudb.cc
+11
-22
storage/tokudb/ha_tokudb.h
storage/tokudb/ha_tokudb.h
+3
-0
storage/tokudb/hatoku_defines.h
storage/tokudb/hatoku_defines.h
+4
-1
storage/tokudb/tokudb_card.h
storage/tokudb/tokudb_card.h
+1
-1
No files found.
mysql-test/suite/tokudb.bugs/r/db756_card_part_hash.result
0 → 100644
View file @
695ce3ad
set default_storage_engine='tokudb';
drop table if exists t;
create table t (id int, x int, primary key (id), key (x)) partition by hash(id) partitions 2;
show indexes from t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t 0 PRIMARY 1 id A 2 NULL NULL BTREE
t 1 x 1 x A NULL NULL NULL YES BTREE
insert into t values (1,1),(3,1),(5,1);
insert into t values (2,1),(4,1),(6,1);
show indexes from t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t 0 PRIMARY 1 id A 6 NULL NULL BTREE
t 1 x 1 x A NULL NULL NULL YES BTREE
analyze table t;
Table Op Msg_type Msg_text
test.t analyze status OK
show indexes from t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t 0 PRIMARY 1 id A 6 NULL NULL BTREE
t 1 x 1 x A 2 NULL NULL YES BTREE
drop table t;
mysql-test/suite/tokudb.bugs/r/db756_card_part_hash_1.result
0 → 100644
View file @
695ce3ad
set default_storage_engine='tokudb';
drop table if exists t;
create table t (id int, x int, primary key (id), key (x)) partition by hash(id) partitions 2;
show indexes from t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t 0 PRIMARY 1 id A 2 NULL NULL BTREE
t 1 x 1 x A NULL NULL NULL YES BTREE
insert into t values (1,1),(3,1),(5,1);
show indexes from t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t 0 PRIMARY 1 id A 4 NULL NULL BTREE
t 1 x 1 x A NULL NULL NULL YES BTREE
analyze table t;
Table Op Msg_type Msg_text
test.t analyze status OK
show indexes from t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t 0 PRIMARY 1 id A 4 NULL NULL BTREE
t 1 x 1 x A 1 NULL NULL YES BTREE
drop table t;
mysql-test/suite/tokudb.bugs/r/db756_card_part_hash_1_pick.result
0 → 100644
View file @
695ce3ad
set default_storage_engine='tokudb';
drop table if exists t;
create table t (id int, x int, primary key (id), key (x)) partition by hash(id) partitions 2;
show indexes from t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t 0 PRIMARY 1 id A 2 NULL NULL BTREE
t 1 x 1 x A NULL NULL NULL YES BTREE
insert into t values (1,1),(3,2),(5,3);
insert into t values (2,1),(4,1),(6,1),(8,1);
show indexes from t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t 0 PRIMARY 1 id A 7 NULL NULL BTREE
t 1 x 1 x A NULL NULL NULL YES BTREE
analyze table t;
Table Op Msg_type Msg_text
test.t analyze status OK
show indexes from t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t 0 PRIMARY 1 id A 7 NULL NULL BTREE
t 1 x 1 x A 1 NULL NULL YES BTREE
drop table t;
mysql-test/suite/tokudb.bugs/r/db756_card_part_hash_2.result
0 → 100644
View file @
695ce3ad
set default_storage_engine='tokudb';
drop table if exists t;
create table t (id int, x int, primary key (id), key (x)) partition by hash(id) partitions 2;
show indexes from t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t 0 PRIMARY 1 id A 2 NULL NULL BTREE
t 1 x 1 x A NULL NULL NULL YES BTREE
insert into t values (2,1),(4,1),(6,1);
show indexes from t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t 0 PRIMARY 1 id A 4 NULL NULL BTREE
t 1 x 1 x A NULL NULL NULL YES BTREE
analyze table t;
Table Op Msg_type Msg_text
test.t analyze status OK
show indexes from t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t 0 PRIMARY 1 id A 4 NULL NULL BTREE
t 1 x 1 x A 1 NULL NULL YES BTREE
drop table t;
mysql-test/suite/tokudb.bugs/r/db756_card_part_hash_2_pick.result
0 → 100644
View file @
695ce3ad
set default_storage_engine='tokudb';
drop table if exists t;
create table t (id int, x int, primary key (id), key (x)) partition by hash(id) partitions 2;
show indexes from t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t 0 PRIMARY 1 id A 2 NULL NULL BTREE
t 1 x 1 x A NULL NULL NULL YES BTREE
insert into t values (1,1),(3,2),(5,3),(7,4);
insert into t values (2,1),(4,1),(6,1);
show indexes from t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t 0 PRIMARY 1 id A 7 NULL NULL BTREE
t 1 x 1 x A NULL NULL NULL YES BTREE
analyze table t;
Table Op Msg_type Msg_text
test.t analyze status OK
show indexes from t;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t 0 PRIMARY 1 id A 7 NULL NULL BTREE
t 1 x 1 x A 7 NULL NULL YES BTREE
drop table t;
mysql-test/suite/tokudb.bugs/t/db756_card_part_hash.test
0 → 100644
View file @
695ce3ad
# DB-756 verify that cardinality is picked from SOME partition
source
include
/
have_tokudb
.
inc
;
source
include
/
have_partition
.
inc
;
set
default_storage_engine
=
'tokudb'
;
disable_warnings
;
drop
table
if
exists
t
;
enable_warnings
;
create
table
t
(
id
int
,
x
int
,
primary
key
(
id
),
key
(
x
))
partition
by
hash
(
id
)
partitions
2
;
show
indexes
from
t
;
insert
into
t
values
(
1
,
1
),(
3
,
1
),(
5
,
1
);
insert
into
t
values
(
2
,
1
),(
4
,
1
),(
6
,
1
);
show
indexes
from
t
;
analyze
table
t
;
show
indexes
from
t
;
drop
table
t
;
mysql-test/suite/tokudb.bugs/t/db756_card_part_hash_1.test
0 → 100644
View file @
695ce3ad
# DB-756 verify that cardinality is picked from the partition where the rows are mapped. in this case, the last partition.
source
include
/
have_tokudb
.
inc
;
source
include
/
have_partition
.
inc
;
set
default_storage_engine
=
'tokudb'
;
disable_warnings
;
drop
table
if
exists
t
;
enable_warnings
;
create
table
t
(
id
int
,
x
int
,
primary
key
(
id
),
key
(
x
))
partition
by
hash
(
id
)
partitions
2
;
show
indexes
from
t
;
insert
into
t
values
(
1
,
1
),(
3
,
1
),(
5
,
1
);
show
indexes
from
t
;
analyze
table
t
;
show
indexes
from
t
;
drop
table
t
;
mysql-test/suite/tokudb.bugs/t/db756_card_part_hash_1_pick.test
0 → 100644
View file @
695ce3ad
# DB-756 verify that cardinality is chosen from the first partition
source
include
/
have_tokudb
.
inc
;
source
include
/
have_partition
.
inc
;
set
default_storage_engine
=
'tokudb'
;
disable_warnings
;
drop
table
if
exists
t
;
enable_warnings
;
create
table
t
(
id
int
,
x
int
,
primary
key
(
id
),
key
(
x
))
partition
by
hash
(
id
)
partitions
2
;
show
indexes
from
t
;
insert
into
t
values
(
1
,
1
),(
3
,
2
),(
5
,
3
);
insert
into
t
values
(
2
,
1
),(
4
,
1
),(
6
,
1
),(
8
,
1
);
show
indexes
from
t
;
analyze
table
t
;
show
indexes
from
t
;
drop
table
t
;
mysql-test/suite/tokudb.bugs/t/db756_card_part_hash_2.test
0 → 100644
View file @
695ce3ad
# DB-756 verify that cardinality is picked from the partition where the rows are mapped. in this case, the first partition.
source
include
/
have_tokudb
.
inc
;
source
include
/
have_partition
.
inc
;
set
default_storage_engine
=
'tokudb'
;
disable_warnings
;
drop
table
if
exists
t
;
enable_warnings
;
create
table
t
(
id
int
,
x
int
,
primary
key
(
id
),
key
(
x
))
partition
by
hash
(
id
)
partitions
2
;
show
indexes
from
t
;
insert
into
t
values
(
2
,
1
),(
4
,
1
),(
6
,
1
);
show
indexes
from
t
;
analyze
table
t
;
show
indexes
from
t
;
drop
table
t
;
mysql-test/suite/tokudb.bugs/t/db756_card_part_hash_2_pick.test
0 → 100644
View file @
695ce3ad
# DB-756 verify that cardinality is chosen from the last partition
source
include
/
have_tokudb
.
inc
;
source
include
/
have_partition
.
inc
;
set
default_storage_engine
=
'tokudb'
;
disable_warnings
;
drop
table
if
exists
t
;
enable_warnings
;
create
table
t
(
id
int
,
x
int
,
primary
key
(
id
),
key
(
x
))
partition
by
hash
(
id
)
partitions
2
;
show
indexes
from
t
;
insert
into
t
values
(
1
,
1
),(
3
,
2
),(
5
,
3
),(
7
,
4
);
insert
into
t
values
(
2
,
1
),(
4
,
1
),(
6
,
1
);
show
indexes
from
t
;
analyze
table
t
;
show
indexes
from
t
;
drop
table
t
;
storage/tokudb/ha_tokudb.cc
View file @
695ce3ad
...
...
@@ -243,23 +243,20 @@ void TOKUDB_SHARE::destroy(void) {
tokudb_pthread_mutex_destroy
(
&
mutex
);
rwlock_destroy
(
&
num_DBs_lock
);
tokudb_pthread_cond_destroy
(
&
m_openclose_cond
);
tokudb_my_free
(
rec_per_key
);
rec_per_key
=
NULL
;
}
// MUST have tokudb_mutex locked on input
static
TOKUDB_SHARE
*
get_share
(
const
char
*
table_name
,
TABLE_SHARE
*
table_share
)
{
TOKUDB_SHARE
*
share
=
NULL
;
int
error
=
0
;
uint
length
;
length
=
(
uint
)
strlen
(
table_name
);
uint
length
=
(
uint
)
strlen
(
table_name
);
if
(
!
(
share
=
(
TOKUDB_SHARE
*
)
my_hash_search
(
&
tokudb_open_tables
,
(
uchar
*
)
table_name
,
length
)))
{
char
*
tmp_name
;
//
// create share and fill it with all zeroes
// hence, all pointers are initialized to NULL
//
share
=
(
TOKUDB_SHARE
*
)
tokudb_my_multi_malloc
(
MYF
(
MY_WME
|
MY_ZEROFILL
),
&
share
,
sizeof
(
*
share
),
&
tmp_name
,
length
+
1
,
...
...
@@ -1596,11 +1593,7 @@ bool ha_tokudb::can_replace_into_be_fast(TABLE_SHARE* table_share, KEY_AND_COL_I
return
ret_val
;
}
int
ha_tokudb
::
initialize_share
(
const
char
*
name
,
int
mode
)
{
int
ha_tokudb
::
initialize_share
(
const
char
*
name
,
int
mode
)
{
int
error
=
0
;
uint64_t
num_rows
=
0
;
DB_TXN
*
txn
=
NULL
;
...
...
@@ -1737,17 +1730,12 @@ int ha_tokudb::initialize_share(
init_hidden_prim_key_info
(
txn
);
// initialize cardinality info from the status dictionary
{
uint
total_key_parts
=
tokudb
::
compute_total_key_parts
(
table_share
);
uint64_t
rec_per_key
[
total_key_parts
];
error
=
tokudb
::
get_card_from_status
(
share
->
status_block
,
txn
,
total_key_parts
,
rec_per_key
);
if
(
error
==
0
)
{
tokudb
::
set_card_in_key_info
(
table
,
total_key_parts
,
rec_per_key
);
}
else
{
for
(
uint
i
=
0
;
i
<
total_key_parts
;
i
++
)
rec_per_key
[
i
]
=
0
;
tokudb
::
set_card_in_key_info
(
table
,
total_key_parts
,
rec_per_key
);
}
share
->
n_rec_per_key
=
tokudb
::
compute_total_key_parts
(
table_share
);
share
->
rec_per_key
=
(
uint64_t
*
)
tokudb_my_realloc
(
share
->
rec_per_key
,
share
->
n_rec_per_key
*
sizeof
(
uint64_t
),
MYF
(
MY_FAE
));
error
=
tokudb
::
get_card_from_status
(
share
->
status_block
,
txn
,
share
->
n_rec_per_key
,
share
->
rec_per_key
);
if
(
error
)
{
for
(
uint
i
=
0
;
i
<
share
->
n_rec_per_key
;
i
++
)
share
->
rec_per_key
[
i
]
=
0
;
}
error
=
0
;
...
...
@@ -5943,6 +5931,7 @@ int ha_tokudb::info(uint flag) {
}
if
((
flag
&
HA_STATUS_CONST
))
{
stats
.
max_data_file_length
=
9223372036854775807ULL
;
tokudb
::
set_card_in_key_info
(
table
,
share
->
n_rec_per_key
,
share
->
rec_per_key
);
}
/* Don't return key if we got an error for the internal primary key */
...
...
storage/tokudb/ha_tokudb.h
View file @
695ce3ad
...
...
@@ -184,6 +184,9 @@ class TOKUDB_SHARE {
enum
{
CLOSED
,
OPENING
,
OPENED
,
CLOSING
,
ERROR
}
m_state
;
int
m_error
;
int
m_initialize_count
;
uint
n_rec_per_key
;
uint64_t
*
rec_per_key
;
};
typedef
struct
st_filter_key_part_info
{
...
...
storage/tokudb/hatoku_defines.h
View file @
695ce3ad
...
...
@@ -441,6 +441,8 @@ static inline void *tokudb_my_malloc(size_t s, myf flags) {
}
static
inline
void
*
tokudb_my_realloc
(
void
*
p
,
size_t
s
,
myf
flags
)
{
if
(
s
==
0
)
return
p
;
#if 50700 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID <= 50799
return
my_realloc
(
0
,
p
,
s
,
flags
);
#else
...
...
@@ -449,7 +451,8 @@ static inline void *tokudb_my_realloc(void *p, size_t s, myf flags) {
}
static
inline
void
tokudb_my_free
(
void
*
ptr
)
{
my_free
(
ptr
);
if
(
ptr
)
my_free
(
ptr
);
}
static
inline
char
*
tokudb_my_strdup
(
const
char
*
p
,
myf
flags
)
{
...
...
storage/tokudb/tokudb_card.h
View file @
695ce3ad
...
...
@@ -217,7 +217,7 @@ namespace tokudb {
// For each key part, put records per key part in *rec_per_key_part[key_part_index].
// Returns 0 if success, otherwise an error number.
// TODO statistical dives into the FT
int
analyze_card
(
DB
*
db
,
DB_TXN
*
txn
,
bool
is_unique
__attribute__
((
unused
))
,
uint64_t
num_key_parts
,
uint64_t
*
rec_per_key_part
,
int
analyze_card
(
DB
*
db
,
DB_TXN
*
txn
,
bool
is_unique
,
uint64_t
num_key_parts
,
uint64_t
*
rec_per_key_part
,
int
(
*
key_compare
)(
DB
*
,
const
DBT
*
,
const
DBT
*
,
uint
),
int
(
*
analyze_progress
)(
void
*
extra
,
uint64_t
rows
),
void
*
progress_extra
)
{
int
error
=
0
;
...
...
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