designate/tools/mysql_pending_notify_bench/runner
Federico Ceratto ecda910c2b Add delayed NOTIFY
Based on specs in https://review.openstack.org/#/c/246515
Add database column zones.pending_notify and migration script
Add Zone Manager Task to perform delayed NOTIFY
Add Admin API method to count zones pending notify

closes-bug: #1498462
partial-bug: #1436210
Change-Id: Ic5c2745bcd2cc057a42cb8edf21ed4c1a3ddc952
Depends-On: If15594099eb7cf74f1c534a05884c2d2501e57e6
2016-02-17 15:24:00 +00:00

96 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
#
# Copyright 2015 Hewlett-Packard Development Company, L.P.
# Licensed under the Apache License, Version 2.0, see LICENSE file
echo "Creating DB and table"
mysql <<EOF
DROP DATABASE IF EXISTS mysqlslap;
CREATE DATABASE mysqlslap;
USE mysqlslap;
CREATE TABLE zones (
id CHAR(32),
version INT(32),
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
name VARCHAR(255),
email VARCHAR(255),
pending_notify BOOLEAN
);
EOF
populate() {
pending_num=$1
not_pending_num=$2
end_num=$(($pending_num+$not_pending_num))
mysql mysqlslap <<EOF
DROP PROCEDURE IF EXISTS populate_not_pending;
DELIMITER #
CREATE PROCEDURE populate_not_pending()
BEGIN
DECLARE i INT UNSIGNED DEFAULT 0;
WHILE i < $not_pending_num DO
INSERT INTO zones (id, version, name, pending_notify) SELECT i, 1, concat(i, '.example.com'), 0;
SET i = i + 1;
END WHILE;
COMMIT;
END #
EOF
mysql mysqlslap <<EOF
DROP PROCEDURE IF EXISTS populate_pending;
DELIMITER #
CREATE PROCEDURE populate_pending()
BEGIN
DECLARE i INT UNSIGNED DEFAULT $not_pending_num;
WHILE i < $end_num DO
INSERT INTO zones (id, version, name, pending_notify) SELECT i, 1, concat(i, '.example.com'), 1;
SET i = i + 1;
END WHILE;
COMMIT;
END #
EOF
echo "Populating non-pending rows"
mysql mysqlslap -e "CALL populate_not_pending();"
echo "Populating pending rows"
mysql mysqlslap -e "CALL populate_pending();"
mysql mysqlslap -e "SELECT COUNT(id) FROM zones WHERE pending_notify = True ORDER BY updated_at DESC;"
mysql mysqlslap -e "SELECT COUNT(id) FROM zones WHERE pending_notify = False ORDER BY updated_at DESC;"
}
run_bench() {
query="SELECT * FROM zones WHERE pending_notify = True ORDER BY updated_at ASC LIMIT 500;"
mysqlslap -C --iterations=100 --concurrency 3 --query "$query" > /dev/null # warmup
mysql mysqlslap -e "EXPLAIN $query"
mysqlslap -C --iterations=100 --concurrency 3 --query "$query"
}
populate 5000 200000
# mysql mysqlslap -e "$query"
echo "Without any index"
run_bench
echo "With pending_notify index"
mysql mysqlslap -e "CREATE INDEX pending_notify_idx ON zones (pending_notify);"
run_bench
echo "With created_at and pending_notify index"
mysql mysqlslap -e "CREATE INDEX created_at_idx ON zones (created_at);"
run_bench
echo "Drop DB"
mysql -e "DROP DATABASE mysqlslap"