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
56126798
Commit
56126798
authored
Aug 18, 2014
by
Rich Prohaska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DB-500 allow simple deletes to use bulk fetch
parent
a2566787
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
246 additions
and
0 deletions
+246
-0
mysql-test/suite/tokudb/r/bf_delete_nonpart.result
mysql-test/suite/tokudb/r/bf_delete_nonpart.result
+54
-0
mysql-test/suite/tokudb/r/bf_delete_trigger.result
mysql-test/suite/tokudb/r/bf_delete_trigger.result
+54
-0
mysql-test/suite/tokudb/t/bf_delete_nonpart.test
mysql-test/suite/tokudb/t/bf_delete_nonpart.test
+67
-0
mysql-test/suite/tokudb/t/bf_delete_trigger.test
mysql-test/suite/tokudb/t/bf_delete_trigger.test
+70
-0
storage/tokudb/ha_tokudb.cc
storage/tokudb/ha_tokudb.cc
+1
-0
No files found.
mysql-test/suite/tokudb/r/bf_delete_nonpart.result
0 → 100644
View file @
56126798
set default_storage_engine='tokudb';
drop table if exists t;
CREATE TABLE `t` (id bigint not null auto_increment primary key, val bigint not null default 0);
INSERT INTO t (id) values (null);
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
SELECT count(*) FROM t;
count(*)
8388608
set tokudb_bulk_fetch = ON;
delete from t where val > 0;
delete from t where val > 0;
delete from t where val > 0;
delete from t where val > 0;
delete from t where val > 0;
delete from t where val > 0;
delete from t where val > 0;
delete from t where val > 0;
delete from t where val > 0;
delete from t where val > 0;
set tokudb_bulk_fetch = OFF;
delete from t where val > 0;
delete from t where val > 0;
delete from t where val > 0;
delete from t where val > 0;
delete from t where val > 0;
delete from t where val > 0;
delete from t where val > 0;
delete from t where val > 0;
delete from t where val > 0;
delete from t where val > 0;
1
drop table t;
mysql-test/suite/tokudb/r/bf_delete_trigger.result
0 → 100644
View file @
56126798
set default_storage_engine='tokudb';
drop table if exists t;
create table t (id bigint not null primary key, x bigint not null);
insert into t values (1,0),(2,0),(3,0),(4,0);
create trigger t_delete before delete on t for each row insert into t values (1000000,0);
begin;
delete from t where x=0;
ERROR HY000: Can't update table 't' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_delete;
create trigger t_delete after delete on t for each row insert into t values (1000000,0);
begin;
delete from t where x=0;
ERROR HY000: Can't update table 't' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_delete;
create trigger t_delete before delete on t for each row delete from t where id=1000000;
begin;
delete from t where x=0;
ERROR HY000: Can't update table 't' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_delete;
create trigger t_delete after delete on t for each row delete from t where id=1000000;
begin;
delete from t where x=0;
ERROR HY000: Can't update table 't' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_delete;
create trigger t_delete before delete on t for each row update t set x=x+1 where id=1000000;
begin;
delete from t where x=0;
ERROR HY000: Can't update table 't' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_delete;
create trigger t_delete after delete on t for each row update t set x=x+1 where id=10000000;
begin;
delete from t where x=0;
ERROR HY000: Can't update table 't' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
rollback;
drop trigger t_delete;
create table count (count bigint not null);
create trigger t_delete before delete on t for each row insert into count select count(*) from t;
begin;
delete from t where x=0;
select * from count;
count
4
3
2
1
rollback;
drop trigger t_delete;
drop table count;
drop table t;
mysql-test/suite/tokudb/t/bf_delete_nonpart.test
0 → 100644
View file @
56126798
# Verify that index scans for delete statements use bulk fetch and are
# at least twice as fast
source
include
/
have_tokudb
.
inc
;
set
default_storage_engine
=
'tokudb'
;
disable_warnings
;
drop
table
if
exists
t
;
enable_warnings
;
CREATE
TABLE
`t`
(
id
bigint
not
null
auto_increment
primary
key
,
val
bigint
not
null
default
0
);
# put 8M rows into t
INSERT
INTO
t
(
id
)
values
(
null
);
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
INSERT
INTO
t
SELECT
null
,
val
FROM
t
;
SELECT
count
(
*
)
FROM
t
;
# run $maxq measurements
let
$maxq
=
10
;
# measure the time to do $maxq deletes from t that affect no rows with bulk fetch ON
set
tokudb_bulk_fetch
=
ON
;
let
$s
=
`select to_seconds(now())`
;
let
$i
=
0
;
while
(
$i
<
$maxq
)
{
delete
from
t
where
val
>
0
;
inc
$i
;
}
let
$time_elapsed_bf_on
=
`select to_seconds(now()) - $s`
;
# measure the time to do $maxq deletes from t that affect no rows with bulk fetch OFF
set
tokudb_bulk_fetch
=
OFF
;
let
$s
=
`select to_seconds(now())`
;
let
$i
=
0
;
while
(
$i
<
$maxq
)
{
delete
from
t
where
val
>
0
;
inc
$i
;
}
let
$time_elapsed_bf_off
=
`select to_seconds(now()) - $s`
;
# verify that a delete scan with bulk fetch ON is at least 2 times faster than with bulk fetch OFF
let
$verdict
=
`select $time_elapsed_bf_off > $time_elapsed_bf_on && ($time_elapsed_bf_off - $time_elapsed_bf_on) / $time_elapsed_bf_on >= 2`
;
echo
$verdict
;
if
(
!
$verdict
)
{
echo
$time_elapsed_bf_on
$time_elapsed_bf_off
;
}
drop
table
t
;
mysql-test/suite/tokudb/t/bf_delete_trigger.test
0 → 100644
View file @
56126798
# verify that delete triggers can not insert, delete, or update rows in the target table
source
include
/
have_tokudb
.
inc
;
set
default_storage_engine
=
'tokudb'
;
disable_warnings
;
drop
table
if
exists
t
;
enable_warnings
;
create
table
t
(
id
bigint
not
null
primary
key
,
x
bigint
not
null
);
insert
into
t
values
(
1
,
0
),(
2
,
0
),(
3
,
0
),(
4
,
0
);
# verify that a before delete trigger can not insert into the target table
create
trigger
t_delete
before
delete
on
t
for
each
row
insert
into
t
values
(
1000000
,
0
);
begin
;
error
1442
;
delete
from
t
where
x
=
0
;
rollback
;
drop
trigger
t_delete
;
# verify that an after delete trigger can not insert into the target table
create
trigger
t_delete
after
delete
on
t
for
each
row
insert
into
t
values
(
1000000
,
0
);
begin
;
error
1442
;
delete
from
t
where
x
=
0
;
rollback
;
drop
trigger
t_delete
;
# verify that a before delete trigger can not delete from the target table
create
trigger
t_delete
before
delete
on
t
for
each
row
delete
from
t
where
id
=
1000000
;
begin
;
error
1442
;
delete
from
t
where
x
=
0
;
rollback
;
drop
trigger
t_delete
;
# verify that an after delete trigger can not delete from the target table
create
trigger
t_delete
after
delete
on
t
for
each
row
delete
from
t
where
id
=
1000000
;
begin
;
error
1442
;
delete
from
t
where
x
=
0
;
rollback
;
drop
trigger
t_delete
;
# verify that a before delete trigger can not update the target table
create
trigger
t_delete
before
delete
on
t
for
each
row
update
t
set
x
=
x
+
1
where
id
=
1000000
;
begin
;
error
1442
;
delete
from
t
where
x
=
0
;
rollback
;
drop
trigger
t_delete
;
# verify that an after delete trigger can not update the target table
create
trigger
t_delete
after
delete
on
t
for
each
row
update
t
set
x
=
x
+
1
where
id
=
10000000
;
begin
;
error
1442
;
delete
from
t
where
x
=
0
;
rollback
;
drop
trigger
t_delete
;
# can execute select on the target table in a delete trigger. it better use a different handler.
create
table
count
(
count
bigint
not
null
);
create
trigger
t_delete
before
delete
on
t
for
each
row
insert
into
count
select
count
(
*
)
from
t
;
begin
;
delete
from
t
where
x
=
0
;
select
*
from
count
;
rollback
;
drop
trigger
t_delete
;
drop
table
count
;
drop
table
t
;
\ No newline at end of file
storage/tokudb/ha_tokudb.cc
View file @
56126798
...
@@ -4370,6 +4370,7 @@ static bool tokudb_do_bulk_fetch(THD *thd) {
...
@@ -4370,6 +4370,7 @@ static bool tokudb_do_bulk_fetch(THD *thd) {
case
SQLCOM_CREATE_TABLE
:
case
SQLCOM_CREATE_TABLE
:
case
SQLCOM_INSERT_SELECT
:
case
SQLCOM_INSERT_SELECT
:
case
SQLCOM_REPLACE_SELECT
:
case
SQLCOM_REPLACE_SELECT
:
case
SQLCOM_DELETE
:
return
THDVAR
(
thd
,
bulk_fetch
)
!=
0
;
return
THDVAR
(
thd
,
bulk_fetch
)
!=
0
;
default:
default:
return
false
;
return
false
;
...
...
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