Added license to benchmarks
This commit is contained in:
parent
2dcdfee7bb
commit
58ebc7847a
@ -1,5 +1,20 @@
|
||||
-- Copyright Data Geekery GmbH
|
||||
--
|
||||
-- Licensed under the Apache License, Version 2.0 (the "License");
|
||||
-- you may not use this file except in compliance with the License.
|
||||
-- You may obtain a copy of the License at
|
||||
--
|
||||
-- http://www.apache.org/licenses/LICENSE-2.0
|
||||
--
|
||||
-- Unless required by applicable law or agreed to in writing, software
|
||||
-- distributed under the License is distributed on an "AS IS" BASIS,
|
||||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
-- See the License for the specific language governing permissions and
|
||||
-- limitations under the License.
|
||||
--
|
||||
-- This version displays actual execution times.
|
||||
-- Beware that according to DB2 licensing, it is not allowed to publish benchmark results
|
||||
|
||||
BEGIN
|
||||
DECLARE CONTINUE HANDLER FOR SQLSTATE '42710' BEGIN END;
|
||||
EXECUTE IMMEDIATE 'CREATE TABLE print (text VARCHAR(500))';
|
||||
@ -63,6 +78,18 @@ BEGIN
|
||||
END REPEAT;
|
||||
END
|
||||
|
||||
SELECT * FROM print;
|
||||
|
||||
DROP TABLE print;
|
||||
SELECT text
|
||||
FROM (
|
||||
SELECT text, 1 AS x
|
||||
FROM print
|
||||
UNION ALL
|
||||
SELECT null, 2 AS x FROM sysibm.dual
|
||||
UNION ALL
|
||||
SELECT 'Copyright Data Geekery GmbH', 3 AS x FROM sysibm.dual
|
||||
UNION ALL
|
||||
SELECT 'https://www.jooq.org/benchmark', 4 AS x FROM sysibm.dual
|
||||
) t
|
||||
ORDER BY x, text;
|
||||
|
||||
DROP TABLE print;
|
||||
@ -1,3 +1,17 @@
|
||||
-- Copyright Data Geekery GmbH
|
||||
--
|
||||
-- Licensed under the Apache License, Version 2.0 (the "License");
|
||||
-- you may not use this file except in compliance with the License.
|
||||
-- You may obtain a copy of the License at
|
||||
--
|
||||
-- http://www.apache.org/licenses/LICENSE-2.0
|
||||
--
|
||||
-- Unless required by applicable law or agreed to in writing, software
|
||||
-- distributed under the License is distributed on an "AS IS" BASIS,
|
||||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
-- See the License for the specific language governing permissions and
|
||||
-- limitations under the License.
|
||||
--
|
||||
-- This version displays actual execution times.
|
||||
-- According to our understanding of DB2 licensing, such benchmark results may be published
|
||||
-- as they cannot be compared to other databases and do not provide absolute time values
|
||||
@ -64,10 +78,23 @@ BEGIN
|
||||
END REPEAT;
|
||||
END
|
||||
|
||||
SELECT
|
||||
run,
|
||||
stmt,
|
||||
CAST(elapsed / MIN(elapsed) OVER() AS DECIMAL(20, 4)) ratio
|
||||
FROM print_relative;
|
||||
|
||||
SELECT run, stmt, ratio, copyright
|
||||
FROM (
|
||||
SELECT
|
||||
run,
|
||||
stmt,
|
||||
CAST(elapsed / MIN(elapsed) OVER() AS DECIMAL(20, 4)) AS ratio,
|
||||
CAST(NULL AS VARCHAR(100)) AS copyright,
|
||||
1 AS x
|
||||
FROM print_relative
|
||||
UNION ALL
|
||||
SELECT null, null, null, null, 2 AS x FROM sysibm.dual
|
||||
UNION ALL
|
||||
SELECT null, null, null, 'Copyright Data Geekery GmbH', 3 AS x FROM sysibm.dual
|
||||
UNION ALL
|
||||
SELECT null, null, null, 'https://www.jooq.org/benchmark', 4 AS x FROM sysibm.dual
|
||||
) t
|
||||
ORDER BY x, run, stmt;
|
||||
|
||||
DROP TABLE print_relative;
|
||||
|
||||
@ -1,136 +0,0 @@
|
||||
-- This version displays actual execution times.
|
||||
-- According to our understanding of DB2 licensing, such benchmark results may be published
|
||||
-- as they cannot be compared to other databases and do not provide absolute time values
|
||||
BEGIN
|
||||
DECLARE CONTINUE HANDLER FOR SQLSTATE '42710' BEGIN END;
|
||||
EXECUTE IMMEDIATE 'CREATE TABLE print_relative (run INTEGER, stmt INTEGER, elapsed DECIMAL(20, 4))';
|
||||
END
|
||||
|
||||
BEGIN
|
||||
DECLARE v_ts TIMESTAMP;
|
||||
DECLARE v_repeat INTEGER DEFAULT 2000;
|
||||
DECLARE v_i INTEGER;
|
||||
DECLARE v_j INTEGER;
|
||||
|
||||
-- Repeat the whole benchmark several times to avoid warmup penalty
|
||||
SET v_i = 1;
|
||||
|
||||
DELETE FROM print_relative;
|
||||
|
||||
REPEAT
|
||||
SET v_j = 1;
|
||||
SET v_ts = CURRENT_TIMESTAMP;
|
||||
|
||||
REPEAT
|
||||
FOR rec AS cur CURSOR FOR
|
||||
SELECT
|
||||
first_name, last_name, count(*) c
|
||||
FROM actor
|
||||
JOIN film_actor ON actor.actor_id = film_actor.actor_id
|
||||
WHERE last_name LIKE 'A%'
|
||||
GROUP BY first_name, last_name
|
||||
ORDER BY count(*) DESC
|
||||
DO
|
||||
BEGIN END;
|
||||
END FOR;
|
||||
|
||||
SET v_j = v_j + 1;
|
||||
UNTIL v_j = v_repeat
|
||||
END REPEAT;
|
||||
|
||||
INSERT INTO print_relative VALUES (v_i, 1, (CURRENT_TIMESTAMP - v_ts));
|
||||
|
||||
SET v_j = 1;
|
||||
SET v_ts = CURRENT_TIMESTAMP;
|
||||
|
||||
REPEAT
|
||||
FOR rec AS cur CURSOR FOR
|
||||
SELECT
|
||||
first_name, last_name,
|
||||
count(*) a
|
||||
FROM (
|
||||
SELECT *
|
||||
FROM actor
|
||||
WHERE last_name LIKE 'A%'
|
||||
) a
|
||||
JOIN film_actor
|
||||
ON a.actor_id = film_actor.actor_id
|
||||
GROUP BY
|
||||
first_name, last_name
|
||||
ORDER BY count(*) DESC
|
||||
DO
|
||||
BEGIN END;
|
||||
END FOR;
|
||||
|
||||
SET v_j = v_j + 1;
|
||||
UNTIL v_j = v_repeat
|
||||
END REPEAT;
|
||||
|
||||
INSERT INTO print_relative VALUES (v_i, 2, (CURRENT_TIMESTAMP - v_ts));
|
||||
|
||||
SET v_j = 1;
|
||||
SET v_ts = CURRENT_TIMESTAMP;
|
||||
|
||||
REPEAT
|
||||
FOR rec AS cur CURSOR FOR
|
||||
SELECT * FROM (
|
||||
SELECT
|
||||
first_name, last_name, (
|
||||
SELECT count(*)
|
||||
FROM film_actor fa
|
||||
WHERE a.actor_id =
|
||||
fa.actor_id
|
||||
) AS c
|
||||
FROM actor a
|
||||
WHERE last_name LIKE 'A%'
|
||||
) a
|
||||
WHERE c > 0
|
||||
ORDER BY c DESC
|
||||
DO
|
||||
BEGIN END;
|
||||
END FOR;
|
||||
|
||||
SET v_j = v_j + 1;
|
||||
UNTIL v_j = v_repeat
|
||||
END REPEAT;
|
||||
|
||||
INSERT INTO print_relative VALUES (v_i, 3, (CURRENT_TIMESTAMP - v_ts));
|
||||
|
||||
SET v_j = 1;
|
||||
SET v_ts = CURRENT_TIMESTAMP;
|
||||
|
||||
REPEAT
|
||||
FOR rec AS cur CURSOR FOR
|
||||
SELECT
|
||||
first_name, last_name, c
|
||||
FROM actor
|
||||
JOIN (
|
||||
SELECT actor_id,count(*) c
|
||||
FROM film_actor
|
||||
GROUP BY actor_id
|
||||
) fa
|
||||
ON actor.actor_id = fa.actor_id
|
||||
WHERE last_name LIKE 'A%'
|
||||
ORDER BY c DESC
|
||||
DO
|
||||
BEGIN END;
|
||||
END FOR;
|
||||
|
||||
SET v_j = v_j + 1;
|
||||
UNTIL v_j = v_repeat
|
||||
END REPEAT;
|
||||
|
||||
INSERT INTO print_relative VALUES (v_i, 4, (CURRENT_TIMESTAMP - v_ts));
|
||||
|
||||
SET v_i = v_i + 1;
|
||||
UNTIL v_i = 5
|
||||
END REPEAT;
|
||||
END
|
||||
|
||||
SELECT
|
||||
run,
|
||||
stmt,
|
||||
CAST(elapsed / MIN(elapsed) OVER() AS DECIMAL(20, 4)) ratio
|
||||
FROM print_relative;
|
||||
|
||||
DROP TABLE print_relative;
|
||||
@ -1,3 +1,17 @@
|
||||
-- Copyright Data Geekery GmbH
|
||||
--
|
||||
-- Licensed under the Apache License, Version 2.0 (the "License");
|
||||
-- you may not use this file except in compliance with the License.
|
||||
-- You may obtain a copy of the License at
|
||||
--
|
||||
-- http://www.apache.org/licenses/LICENSE-2.0
|
||||
--
|
||||
-- Unless required by applicable law or agreed to in writing, software
|
||||
-- distributed under the License is distributed on an "AS IS" BASIS,
|
||||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
-- See the License for the specific language governing permissions and
|
||||
-- limitations under the License.
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS print (text VARCHAR(500));
|
||||
|
||||
delimiter //
|
||||
@ -65,7 +79,14 @@ delimiter ;
|
||||
|
||||
CALL benchmark();
|
||||
|
||||
SELECT * FROM print;
|
||||
SELECT text
|
||||
FROM print
|
||||
UNION ALL
|
||||
SELECT null
|
||||
UNION ALL
|
||||
SELECT 'Copyright Data Geekery GmbH'
|
||||
UNION ALL
|
||||
SELECT 'https://www.jooq.org/benchmark';
|
||||
|
||||
DROP PROCEDURE benchmark;
|
||||
|
||||
|
||||
@ -1,3 +1,17 @@
|
||||
-- Copyright Data Geekery GmbH
|
||||
--
|
||||
-- Licensed under the Apache License, Version 2.0 (the "License");
|
||||
-- you may not use this file except in compliance with the License.
|
||||
-- You may obtain a copy of the License at
|
||||
--
|
||||
-- http://www.apache.org/licenses/LICENSE-2.0
|
||||
--
|
||||
-- Unless required by applicable law or agreed to in writing, software
|
||||
-- distributed under the License is distributed on an "AS IS" BASIS,
|
||||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
-- See the License for the specific language governing permissions and
|
||||
-- limitations under the License.
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS print_relative (run INT, stmt INT, elapsed BIGINT);
|
||||
|
||||
delimiter //
|
||||
@ -68,8 +82,16 @@ CALL benchmark();
|
||||
SELECT
|
||||
run,
|
||||
stmt,
|
||||
CAST(elapsed / MIN(elapsed) OVER() AS DECIMAL(20, 4)) ratio
|
||||
FROM print_relative;
|
||||
CAST(elapsed / MIN(elapsed) OVER() AS DECIMAL(20, 4)) ratio,
|
||||
' ' `Copyright Data Geekery GmbH`
|
||||
FROM print_relative
|
||||
UNION ALL
|
||||
SELECT null, null, null, null
|
||||
UNION ALL
|
||||
SELECT null, null, null, 'Copyright Data Geekery GmbH'
|
||||
UNION ALL
|
||||
SELECT null, null, null, 'https://www.jooq.org/benchmark';
|
||||
|
||||
|
||||
DROP PROCEDURE benchmark;
|
||||
|
||||
|
||||
@ -1,3 +1,17 @@
|
||||
-- Copyright Data Geekery GmbH
|
||||
--
|
||||
-- Licensed under the Apache License, Version 2.0 (the "License");
|
||||
-- you may not use this file except in compliance with the License.
|
||||
-- You may obtain a copy of the License at
|
||||
--
|
||||
-- http://www.apache.org/licenses/LICENSE-2.0
|
||||
--
|
||||
-- Unless required by applicable law or agreed to in writing, software
|
||||
-- distributed under the License is distributed on an "AS IS" BASIS,
|
||||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
-- See the License for the specific language governing permissions and
|
||||
-- limitations under the License.
|
||||
--
|
||||
-- This version displays actual execution times.
|
||||
-- Beware that according to Oracle licensing, it is not allowed to publish benchmark results
|
||||
SET SERVEROUTPUT ON
|
||||
@ -36,5 +50,9 @@ BEGIN
|
||||
dbms_output.put_line('Run ' || r ||', Statement 2 : ' || (SYSTIMESTAMP - v_ts));
|
||||
dbms_output.put_line('');
|
||||
END LOOP;
|
||||
|
||||
dbms_output.put_line('');
|
||||
dbms_output.put_line('Copyright Data Geekery GmbH');
|
||||
dbms_output.put_line('https://www.jooq.org/benchmark');
|
||||
END;
|
||||
/
|
||||
|
||||
@ -1,3 +1,17 @@
|
||||
-- Copyright Data Geekery GmbH
|
||||
--
|
||||
-- Licensed under the Apache License, Version 2.0 (the "License");
|
||||
-- you may not use this file except in compliance with the License.
|
||||
-- You may obtain a copy of the License at
|
||||
--
|
||||
-- http://www.apache.org/licenses/LICENSE-2.0
|
||||
--
|
||||
-- Unless required by applicable law or agreed to in writing, software
|
||||
-- distributed under the License is distributed on an "AS IS" BASIS,
|
||||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
-- See the License for the specific language governing permissions and
|
||||
-- limitations under the License.
|
||||
--
|
||||
-- This version displays relative execution times (fastest execution = 1)
|
||||
-- According to our understanding of Oracle licensing, such benchmark results may be published
|
||||
-- as they cannot be compared to other databases and do not provide absolute time values
|
||||
@ -54,6 +68,10 @@ BEGIN
|
||||
', Statement ' || rec.stmt ||
|
||||
' : ' || rec.ratio);
|
||||
END LOOP;
|
||||
|
||||
dbms_output.put_line('');
|
||||
dbms_output.put_line('Copyright Data Geekery GmbH');
|
||||
dbms_output.put_line('https://www.jooq.org/benchmark');
|
||||
END;
|
||||
/
|
||||
|
||||
|
||||
@ -1,118 +0,0 @@
|
||||
-- This version displays relative execution times (fastest execution = 1)
|
||||
-- According to our understanding of Oracle licensing, such benchmark results may be published
|
||||
-- as they cannot be compared to other databases and do not provide absolute time values
|
||||
SET SERVEROUTPUT ON
|
||||
CREATE TABLE results (
|
||||
run NUMBER(2),
|
||||
stmt NUMBER(2),
|
||||
elapsed NUMBER
|
||||
);
|
||||
|
||||
DECLARE
|
||||
v_ts TIMESTAMP WITH TIME ZONE;
|
||||
v_repeat CONSTANT NUMBER := 2000;
|
||||
BEGIN
|
||||
|
||||
-- Repeat the whole benchmark several times to avoid warmup penalty
|
||||
FOR r IN 1..5 LOOP
|
||||
v_ts := SYSTIMESTAMP;
|
||||
|
||||
FOR i IN 1..v_repeat LOOP
|
||||
FOR rec IN (
|
||||
SELECT
|
||||
first_name, last_name, count(*) c
|
||||
FROM actor
|
||||
JOIN film_actor ON actor.actor_id = film_actor.actor_id
|
||||
WHERE last_name LIKE 'A%'
|
||||
GROUP BY first_name, last_name
|
||||
ORDER BY count(*) DESC
|
||||
) LOOP
|
||||
NULL;
|
||||
END LOOP;
|
||||
END LOOP;
|
||||
|
||||
INSERT INTO results VALUES (r, 1, SYSDATE + ((SYSTIMESTAMP - v_ts) * 86400) - SYSDATE);
|
||||
v_ts := SYSTIMESTAMP;
|
||||
|
||||
FOR i IN 1..v_repeat LOOP
|
||||
FOR rec IN (
|
||||
SELECT
|
||||
first_name, last_name,
|
||||
count(*) a
|
||||
FROM (
|
||||
SELECT *
|
||||
FROM actor
|
||||
WHERE last_name LIKE 'A%'
|
||||
) a
|
||||
JOIN film_actor
|
||||
ON a.actor_id = film_actor.actor_id
|
||||
GROUP BY
|
||||
first_name, last_name
|
||||
ORDER BY count(*) DESC
|
||||
) LOOP
|
||||
NULL;
|
||||
END LOOP;
|
||||
END LOOP;
|
||||
|
||||
INSERT INTO results VALUES (r, 2, SYSDATE + ((SYSTIMESTAMP - v_ts) * 86400) - SYSDATE);
|
||||
v_ts := SYSTIMESTAMP;
|
||||
|
||||
FOR i IN 1..v_repeat LOOP
|
||||
FOR rec IN (
|
||||
SELECT * FROM (
|
||||
SELECT
|
||||
first_name, last_name, (
|
||||
SELECT count(*)
|
||||
FROM film_actor fa
|
||||
WHERE a.actor_id =
|
||||
fa.actor_id
|
||||
) AS c
|
||||
FROM actor a
|
||||
WHERE last_name LIKE 'A%'
|
||||
) a
|
||||
WHERE c > 0
|
||||
ORDER BY c DESC
|
||||
) LOOP
|
||||
NULL;
|
||||
END LOOP;
|
||||
END LOOP;
|
||||
|
||||
INSERT INTO results VALUES (r, 3, SYSDATE + ((SYSTIMESTAMP - v_ts) * 86400) - SYSDATE);
|
||||
v_ts := SYSTIMESTAMP;
|
||||
|
||||
FOR i IN 1..v_repeat LOOP
|
||||
FOR rec IN (
|
||||
SELECT
|
||||
first_name, last_name, c
|
||||
FROM actor
|
||||
JOIN (
|
||||
SELECT actor_id,count(*) c
|
||||
FROM film_actor
|
||||
GROUP BY actor_id
|
||||
) fa
|
||||
ON actor.actor_id = fa.actor_id
|
||||
WHERE last_name LIKE 'A%'
|
||||
ORDER BY c DESC
|
||||
) LOOP
|
||||
NULL;
|
||||
END LOOP;
|
||||
END LOOP;
|
||||
|
||||
INSERT INTO results VALUES (r, 4, SYSDATE + ((SYSTIMESTAMP - v_ts) * 86400) - SYSDATE);
|
||||
END LOOP;
|
||||
|
||||
FOR rec IN (
|
||||
SELECT
|
||||
run, stmt,
|
||||
CAST(elapsed / MIN(elapsed) OVER() AS NUMBER(10, 5)) ratio
|
||||
FROM results
|
||||
)
|
||||
LOOP
|
||||
dbms_output.put_line('Run ' || rec.run ||
|
||||
', Statement ' || rec.stmt ||
|
||||
' : ' || rec.ratio);
|
||||
END LOOP;
|
||||
END;
|
||||
/
|
||||
|
||||
DROP TABLE results;
|
||||
@ -1,3 +1,17 @@
|
||||
-- Copyright Data Geekery GmbH
|
||||
--
|
||||
-- Licensed under the Apache License, Version 2.0 (the "License");
|
||||
-- you may not use this file except in compliance with the License.
|
||||
-- You may obtain a copy of the License at
|
||||
--
|
||||
-- http://www.apache.org/licenses/LICENSE-2.0
|
||||
--
|
||||
-- Unless required by applicable law or agreed to in writing, software
|
||||
-- distributed under the License is distributed on an "AS IS" BASIS,
|
||||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
-- See the License for the specific language governing permissions and
|
||||
-- limitations under the License.
|
||||
--
|
||||
DO $$
|
||||
DECLARE
|
||||
v_ts TIMESTAMP;
|
||||
@ -38,4 +52,8 @@ BEGIN
|
||||
RAISE INFO 'Run %, Statement 2: %', r, (clock_timestamp() - v_ts);
|
||||
RAISE INFO '';
|
||||
END LOOP;
|
||||
|
||||
RAISE INFO '';
|
||||
RAISE INFO 'Copyright Data Geekery GmbH';
|
||||
RAISE INFO 'https://www.jooq.org/benchmark';
|
||||
END$$;
|
||||
@ -1,3 +1,17 @@
|
||||
-- Copyright Data Geekery GmbH
|
||||
--
|
||||
-- Licensed under the Apache License, Version 2.0 (the "License");
|
||||
-- you may not use this file except in compliance with the License.
|
||||
-- You may obtain a copy of the License at
|
||||
--
|
||||
-- http://www.apache.org/licenses/LICENSE-2.0
|
||||
--
|
||||
-- Unless required by applicable law or agreed to in writing, software
|
||||
-- distributed under the License is distributed on an "AS IS" BASIS,
|
||||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
-- See the License for the specific language governing permissions and
|
||||
-- limitations under the License.
|
||||
--
|
||||
DO $$
|
||||
DECLARE
|
||||
v_ts TIMESTAMP;
|
||||
@ -56,4 +70,8 @@ BEGIN
|
||||
FOR i IN 1..array_length(run, 1) LOOP
|
||||
RAISE INFO 'RUN %, Statement %: %', run[i], stmt[i], CAST(elapsed[i] / min_elapsed AS DECIMAL(10, 5));
|
||||
END LOOP;
|
||||
|
||||
RAISE INFO '';
|
||||
RAISE INFO 'Copyright Data Geekery GmbH';
|
||||
RAISE INFO 'https://www.jooq.org/benchmark';
|
||||
END$$;
|
||||
@ -1,120 +0,0 @@
|
||||
DO $$
|
||||
DECLARE
|
||||
v_ts TIMESTAMP;
|
||||
v_repeat CONSTANT INT := 2000;
|
||||
rec RECORD;
|
||||
run INT[];
|
||||
stmt INT[];
|
||||
elapsed DECIMAL[];
|
||||
min_elapsed DECIMAL;
|
||||
i INT := 1;
|
||||
BEGIN
|
||||
|
||||
-- Repeat the whole benchmark several times to avoid warmup penalty
|
||||
FOR r IN 1..5 LOOP
|
||||
v_ts := clock_timestamp();
|
||||
|
||||
FOR i IN 1..v_repeat LOOP
|
||||
FOR rec IN (
|
||||
SELECT
|
||||
first_name, last_name, count(*) c
|
||||
FROM actor
|
||||
JOIN film_actor ON actor.actor_id = film_actor.actor_id
|
||||
WHERE last_name LIKE 'A%'
|
||||
GROUP BY first_name, last_name
|
||||
ORDER BY count(*) DESC
|
||||
) LOOP
|
||||
NULL;
|
||||
END LOOP;
|
||||
END LOOP;
|
||||
|
||||
run[i] := r;
|
||||
stmt[i] := 1;
|
||||
elapsed[i] := (EXTRACT(EPOCH FROM CAST(clock_timestamp() AS TIMESTAMP)) - EXTRACT(EPOCH FROM v_ts));
|
||||
i := i + 1;
|
||||
v_ts := clock_timestamp();
|
||||
|
||||
FOR i IN 1..v_repeat LOOP
|
||||
FOR rec IN (
|
||||
SELECT
|
||||
first_name, last_name,
|
||||
count(*) a
|
||||
FROM (
|
||||
SELECT *
|
||||
FROM actor
|
||||
WHERE last_name LIKE 'A%'
|
||||
) a
|
||||
JOIN film_actor
|
||||
ON a.actor_id = film_actor.actor_id
|
||||
GROUP BY
|
||||
first_name, last_name
|
||||
ORDER BY count(*) DESC
|
||||
) LOOP
|
||||
NULL;
|
||||
END LOOP;
|
||||
END LOOP;
|
||||
|
||||
run[i] := r;
|
||||
stmt[i] := 2;
|
||||
elapsed[i] := (EXTRACT(EPOCH FROM CAST(clock_timestamp() AS TIMESTAMP)) - EXTRACT(EPOCH FROM v_ts));
|
||||
i := i + 1;
|
||||
v_ts := clock_timestamp();
|
||||
|
||||
FOR i IN 1..v_repeat LOOP
|
||||
FOR rec IN (
|
||||
SELECT * FROM (
|
||||
SELECT
|
||||
first_name, last_name, (
|
||||
SELECT count(*)
|
||||
FROM film_actor fa
|
||||
WHERE a.actor_id =
|
||||
fa.actor_id
|
||||
) AS c
|
||||
FROM actor a
|
||||
WHERE last_name LIKE 'A%'
|
||||
) a
|
||||
WHERE c > 0
|
||||
ORDER BY c DESC
|
||||
) LOOP
|
||||
NULL;
|
||||
END LOOP;
|
||||
END LOOP;
|
||||
|
||||
run[i] := r;
|
||||
stmt[i] := 3;
|
||||
elapsed[i] := (EXTRACT(EPOCH FROM CAST(clock_timestamp() AS TIMESTAMP)) - EXTRACT(EPOCH FROM v_ts));
|
||||
i := i + 1;
|
||||
v_ts := clock_timestamp();
|
||||
|
||||
FOR i IN 1..v_repeat LOOP
|
||||
FOR rec IN (
|
||||
SELECT
|
||||
first_name, last_name, c
|
||||
FROM actor
|
||||
JOIN (
|
||||
SELECT actor_id,count(*) c
|
||||
FROM film_actor
|
||||
GROUP BY actor_id
|
||||
) fa
|
||||
ON actor.actor_id = fa.actor_id
|
||||
WHERE last_name LIKE 'A%'
|
||||
ORDER BY c DESC
|
||||
) LOOP
|
||||
NULL;
|
||||
END LOOP;
|
||||
END LOOP;
|
||||
|
||||
run[i] := r;
|
||||
stmt[i] := 4;
|
||||
elapsed[i] := (EXTRACT(EPOCH FROM CAST(clock_timestamp() AS TIMESTAMP)) - EXTRACT(EPOCH FROM v_ts));
|
||||
i := i + 1;
|
||||
END LOOP;
|
||||
|
||||
SELECT min(t.elapsed)
|
||||
INTO min_elapsed
|
||||
FROM unnest(elapsed) AS t(elapsed);
|
||||
|
||||
FOR i IN 1..array_length(run, 1) LOOP
|
||||
RAISE INFO 'RUN %, Statement %: %', run[i], stmt[i], CAST(elapsed[i] / min_elapsed AS DECIMAL(10, 5));
|
||||
END LOOP;
|
||||
END$$;
|
||||
@ -1,3 +1,17 @@
|
||||
-- Copyright Data Geekery GmbH
|
||||
--
|
||||
-- Licensed under the Apache License, Version 2.0 (the "License");
|
||||
-- you may not use this file except in compliance with the License.
|
||||
-- You may obtain a copy of the License at
|
||||
--
|
||||
-- http://www.apache.org/licenses/LICENSE-2.0
|
||||
--
|
||||
-- Unless required by applicable law or agreed to in writing, software
|
||||
-- distributed under the License is distributed on an "AS IS" BASIS,
|
||||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
-- See the License for the specific language governing permissions and
|
||||
-- limitations under the License.
|
||||
--
|
||||
-- This version displays actual execution times.
|
||||
-- Beware that according to SQL Server licensing, it is not allowed to publish benchmark results
|
||||
DECLARE @ts DATETIME;
|
||||
@ -44,7 +58,7 @@ BEGIN
|
||||
END;
|
||||
|
||||
DEALLOCATE @s1;
|
||||
PRINT 'Run ' + @r + ', Statement 1: ' + CAST(DATEDIFF(ms, @ts, current_timestamp) AS VARCHAR) + 'ms';
|
||||
PRINT 'Run ' + CAST(@r AS VARCHAR) + ', Statement 1: ' + CAST(DATEDIFF(ms, @ts, current_timestamp) AS VARCHAR) + 'ms';
|
||||
|
||||
SET @ts = current_timestamp;
|
||||
SET @i = 0;
|
||||
@ -63,8 +77,10 @@ BEGIN
|
||||
END;
|
||||
|
||||
DEALLOCATE @s2;
|
||||
PRINT 'Run ' + @r + ', Statement 2: ' + CAST(DATEDIFF(ms, @ts, current_timestamp) AS VARCHAR) + 'ms';
|
||||
PRINT '';
|
||||
PRINT 'Run ' + CAST(@r AS VARCHAR) + ', Statement 2: ' + CAST(DATEDIFF(ms, @ts, current_timestamp) AS VARCHAR) + 'ms';
|
||||
END;
|
||||
|
||||
PRINT '';
|
||||
PRINT 'Copyright Data Geekery GmbH';
|
||||
PRINT 'https://www.jooq.org/benchmark';
|
||||
|
||||
|
||||
@ -1,3 +1,17 @@
|
||||
-- Copyright Data Geekery GmbH
|
||||
--
|
||||
-- Licensed under the Apache License, Version 2.0 (the "License");
|
||||
-- you may not use this file except in compliance with the License.
|
||||
-- You may obtain a copy of the License at
|
||||
--
|
||||
-- http://www.apache.org/licenses/LICENSE-2.0
|
||||
--
|
||||
-- Unless required by applicable law or agreed to in writing, software
|
||||
-- distributed under the License is distributed on an "AS IS" BASIS,
|
||||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
-- See the License for the specific language governing permissions and
|
||||
-- limitations under the License.
|
||||
--
|
||||
-- This version displays relative execution times (fastest execution = 1)
|
||||
-- According to our understanding of SQL Server licensing, such benchmark results may be published
|
||||
-- as they cannot be compared to other databases and do not provide absolute time values
|
||||
@ -74,4 +88,10 @@ BEGIN
|
||||
END;
|
||||
|
||||
SELECT 'Run ' + CAST(run AS VARCHAR) + ', Statement ' + CAST(stmt AS VARCHAR) + ': ' + CAST(CAST(elapsed / MIN(elapsed) OVER() AS DECIMAL(10, 5)) AS VARCHAR)
|
||||
FROM @results;
|
||||
FROM @results
|
||||
UNION ALL
|
||||
SELECT ''
|
||||
UNION ALL
|
||||
SELECT 'Copyright Data Geekery GmbH'
|
||||
UNION ALL
|
||||
SELECT 'https://www.jooq.org/benchmark';
|
||||
|
||||
@ -1,158 +0,0 @@
|
||||
-- This version displays relative execution times (fastest execution = 1)
|
||||
-- According to our understanding of SQL Server licensing, such benchmark results may be published
|
||||
-- as they cannot be compared to other databases and do not provide absolute time values
|
||||
DECLARE @ts DATETIME;
|
||||
DECLARE @repeat INT = 2000;
|
||||
DECLARE @r INT;
|
||||
DECLARE @i INT;
|
||||
DECLARE @dummy1 VARCHAR;
|
||||
DECLARE @dummy2 VARCHAR;
|
||||
DECLARE @dummy3 INT;
|
||||
|
||||
DECLARE @s1 CURSOR;
|
||||
DECLARE @s2 CURSOR;
|
||||
DECLARE @s3 CURSOR;
|
||||
DECLARE @s4 CURSOR;
|
||||
|
||||
DECLARE @results TABLE (
|
||||
run INT,
|
||||
stmt INT,
|
||||
elapsed DECIMAL
|
||||
);
|
||||
|
||||
SET @r = 0;
|
||||
WHILE @r < 5
|
||||
BEGIN
|
||||
SET @r = @r + 1
|
||||
|
||||
SET @s1 = CURSOR FOR
|
||||
SELECT
|
||||
first_name, last_name, count(*) c
|
||||
FROM actor
|
||||
JOIN film_actor ON actor.actor_id = film_actor.actor_id
|
||||
WHERE last_name LIKE 'A%'
|
||||
GROUP BY first_name, last_name
|
||||
ORDER BY count(*) DESC
|
||||
|
||||
SET @s2 = CURSOR FOR
|
||||
SELECT
|
||||
first_name, last_name,
|
||||
count(*) a
|
||||
FROM (
|
||||
SELECT *
|
||||
FROM actor
|
||||
WHERE last_name LIKE 'A%'
|
||||
) a
|
||||
JOIN film_actor
|
||||
ON a.actor_id = film_actor.actor_id
|
||||
GROUP BY
|
||||
first_name, last_name
|
||||
ORDER BY count(*) DESC
|
||||
|
||||
SET @s3 = CURSOR FOR
|
||||
SELECT * FROM (
|
||||
SELECT
|
||||
first_name, last_name, (
|
||||
SELECT count(*)
|
||||
FROM film_actor fa
|
||||
WHERE a.actor_id =
|
||||
fa.actor_id
|
||||
) AS c
|
||||
FROM actor a
|
||||
WHERE last_name LIKE 'A%'
|
||||
) a
|
||||
WHERE c > 0
|
||||
ORDER BY c DESC
|
||||
|
||||
SET @s4 = CURSOR FOR
|
||||
SELECT
|
||||
first_name, last_name, c
|
||||
FROM actor
|
||||
JOIN (
|
||||
SELECT actor_id,count(*) c
|
||||
FROM film_actor
|
||||
GROUP BY actor_id
|
||||
) fa
|
||||
ON actor.actor_id = fa.actor_id
|
||||
WHERE last_name LIKE 'A%'
|
||||
ORDER BY c DESC
|
||||
|
||||
SET @ts = current_timestamp;
|
||||
SET @i = 0;
|
||||
WHILE @i < @repeat
|
||||
BEGIN
|
||||
SET @i = @i + 1
|
||||
|
||||
OPEN @s1;
|
||||
FETCH NEXT FROM @s1 INTO @dummy1, @dummy2, @dummy3;
|
||||
WHILE @@FETCH_STATUS = 0
|
||||
BEGIN
|
||||
FETCH NEXT FROM @s1 INTO @dummy1, @dummy2, @dummy3;
|
||||
END;
|
||||
|
||||
CLOSE @s1;
|
||||
END;
|
||||
|
||||
DEALLOCATE @s1;
|
||||
INSERT INTO @results VALUES (@r, 1, DATEDIFF(ms, @ts, current_timestamp));
|
||||
|
||||
SET @ts = current_timestamp;
|
||||
SET @i = 0;
|
||||
WHILE @i < @repeat
|
||||
BEGIN
|
||||
SET @i = @i + 1
|
||||
|
||||
OPEN @s2;
|
||||
FETCH NEXT FROM @s2 INTO @dummy1, @dummy2, @dummy3;
|
||||
WHILE @@FETCH_STATUS = 0
|
||||
BEGIN
|
||||
FETCH NEXT FROM @s2 INTO @dummy1, @dummy2, @dummy3;
|
||||
END;
|
||||
|
||||
CLOSE @s2;
|
||||
END;
|
||||
|
||||
DEALLOCATE @s2;
|
||||
INSERT INTO @results VALUES (@r, 2, DATEDIFF(ms, @ts, current_timestamp));
|
||||
|
||||
SET @ts = current_timestamp;
|
||||
SET @i = 0;
|
||||
WHILE @i < @repeat
|
||||
BEGIN
|
||||
SET @i = @i + 1
|
||||
|
||||
OPEN @s3;
|
||||
FETCH NEXT FROM @s3 INTO @dummy1, @dummy2, @dummy3;
|
||||
WHILE @@FETCH_STATUS = 0
|
||||
BEGIN
|
||||
FETCH NEXT FROM @s3 INTO @dummy1, @dummy2, @dummy3;
|
||||
END;
|
||||
|
||||
CLOSE @s3;
|
||||
END;
|
||||
|
||||
DEALLOCATE @s3;
|
||||
INSERT INTO @results VALUES (@r, 3, DATEDIFF(ms, @ts, current_timestamp));
|
||||
|
||||
SET @ts = current_timestamp;
|
||||
SET @i = 0;
|
||||
WHILE @i < @repeat
|
||||
BEGIN
|
||||
SET @i = @i + 1
|
||||
|
||||
OPEN @s4;
|
||||
FETCH NEXT FROM @s4 INTO @dummy1, @dummy2, @dummy3;
|
||||
WHILE @@FETCH_STATUS = 0
|
||||
BEGIN
|
||||
FETCH NEXT FROM @s4 INTO @dummy1, @dummy2, @dummy3;
|
||||
END;
|
||||
|
||||
CLOSE @s4;
|
||||
END;
|
||||
|
||||
DEALLOCATE @s4;
|
||||
INSERT INTO @results VALUES (@r, 4, DATEDIFF(ms, @ts, current_timestamp));
|
||||
END;
|
||||
|
||||
SELECT 'Run ' + CAST(run AS VARCHAR) + ', Statement ' + CAST(stmt AS VARCHAR) + ': ' + CAST(CAST(elapsed / MIN(elapsed) OVER() AS DECIMAL(10, 5)) AS VARCHAR)
|
||||
FROM @results;
|
||||
Loading…
Reference in New Issue
Block a user