Skip to content

Commit

Permalink
Merge 11.0 into 11.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Mar 29, 2023
2 parents 7bd225e + 5e01255 commit 2b61ff8
Show file tree
Hide file tree
Showing 216 changed files with 3,861 additions and 3,325 deletions.
16 changes: 8 additions & 8 deletions Docs/optimizer_costs.txt
Expand Up @@ -23,7 +23,7 @@ The MariaDB server is started with the options:
- InnoDB is a clustered engine where secondary indexes has to use
the clustered index to find a row (not a common case among storage engines).

The old assumption in the optimzer has 'always' been that
The old assumption in the optimizer has 'always' been that
1 cost = 1 seek = 1 index = 1 row lookup = 0.10ms.
However 1 seek != 1 index or row look and this has not been reflected in
most other cost.
Expand Down Expand Up @@ -135,7 +135,7 @@ MariaDB [test]> select 885402302809000-884884140290000;
As seen above, the above gives the total statement time not the time
spent to access the tables.

In the end, I dediced to use analyze to find out the cost of the table
In the end, I decided to use analyze to find out the cost of the table
actions:

For example: Finding out table scan timing (and thus costs):
Expand All @@ -147,7 +147,7 @@ r_table_time_ms": 1189.239022
Calculating 'optimizer_where_cost'
==================================

To make the WHERE cost reasonble (not too low) we are assuming there is
To make the WHERE cost reasonable (not too low) we are assuming there is
2 simple conditions in the default 'WHERE clause'

MariaDB [test]> select benchmark(100000000,l_commitDate >= '2000-01-01' and l_tax >= 0.0) from test.check_costs limit 1;
Expand Down Expand Up @@ -300,7 +300,7 @@ r_table_time_ms: 12.47830611
Note that for sequence index and table scan is the same thing.
We need to have a row_copy/key_copy cost as this is used when doing
an key lookup for sequence. Setting these to 50% of the full cost
should be sufficent for now.
should be sufficient for now.

Calculation sequence_scan_cost:

Expand Down Expand Up @@ -982,7 +982,7 @@ MyRocks Range scan
select sum(l_orderkey) from test.check_costs_rocksdb force index(l_suppkey) where l_suppkey >= 0 and l_partkey >=0 and l_discount>=0.0

The MyRocks engine estimates the number of rows both for the table and
for the to be about 2M, double the real ammount.
for the to be about 2M, double the real amount.

The timing and costs from check_costs.pl are:

Expand Down Expand Up @@ -1014,15 +1014,15 @@ is heap with binary-tree indexes.
Ideas of how to fix this:

- Change KEY_LOOKUP_COST, INDEX_BLOCK_COPY_COST and ROW_LOOKUP_COST
(for clustered index) to take into account the hight of the B tree.
(for clustered index) to take into account the height of the B tree.


Observations
============

Ratio between table scan and range scan

Quereyies used:
Queries used:
select sum(l_quantity) from check_costs_aria;
select sum(l_orderkey) from test.check_costs_aria force index(l_suppkey) where l_suppkey >= 0 and l_partkey >=0 and l_discount>=0.0;

Expand Down Expand Up @@ -1086,7 +1086,7 @@ Call graph

-> KEY_COPY_COST = 1.33/1.96 = 0.6785 parts of the index_read_next

Total cost increase from 2 -> 4 key parts = 1.96 / 1.40 = 40%
Total cost increases from 2 -> 4 key parts = 1.96 / 1.40 = 40%
This includes the additional work in having more key pages, more work in
finding next key (if key parts are packed or possible null) ,and copying
the key parts to the record
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/backup_syntax.test
@@ -1,5 +1,5 @@
########################################################################
# Tests things releated to syntax of BACKUP STAGE (MDEV-5336)
# Tests things related to syntax of BACKUP STAGE (MDEV-5336)
########################################################################

--source include/have_innodb.inc
Expand Down
213 changes: 213 additions & 0 deletions mysql-test/main/func_format.result
@@ -0,0 +1,213 @@
# MDEV-19629: Implement MySQL 8.0 native functions: format_bytes(), format_pico_time() and ps_thread_id()
#
# Tests for the Performance Schema native function format_pico_time()
#

SELECT format_pico_time(NULL);
format_pico_time(NULL)
NULL

SELECT format_pico_time(0);
format_pico_time(0)
0 ps

SELECT format_pico_time(1);
format_pico_time(1)
1 ps

SELECT format_pico_time(999);
format_pico_time(999)
999 ps

SELECT format_pico_time(1000);
format_pico_time(1000)
1.00 ns

SELECT format_pico_time(1001);
format_pico_time(1001)
1.00 ns

SELECT format_pico_time(999999);
format_pico_time(999999)
1000.00 ns

SELECT format_pico_time(1000000);
format_pico_time(1000000)
1.00 us

SELECT format_pico_time(1000001);
format_pico_time(1000001)
1.00 us

SELECT format_pico_time(1010000);
format_pico_time(1010000)
1.01 us

SELECT format_pico_time(987654321);
format_pico_time(987654321)
987.65 us

SELECT format_pico_time(1000000000);
format_pico_time(1000000000)
1.00 ms

SELECT format_pico_time(999876000000);
format_pico_time(999876000000)
999.88 ms

SELECT format_pico_time(999999999999);
format_pico_time(999999999999)
1000.00 ms

SELECT format_pico_time(1000000000000);
format_pico_time(1000000000000)
1.00 s

SELECT format_pico_time(59000000000000);
format_pico_time(59000000000000)
59.00 s

SELECT format_pico_time(60000000000000);
format_pico_time(60000000000000)
1.00 min

SELECT format_pico_time(3549000000000000);
format_pico_time(3549000000000000)
59.15 min

SELECT format_pico_time(3599000000000000);
format_pico_time(3599000000000000)
59.98 min

SELECT format_pico_time(3600000000000000);
format_pico_time(3600000000000000)
1.00 h

SELECT format_pico_time(power(2, 63));
format_pico_time(power(2, 63))
106.75 d

SELECT format_pico_time((power(2, 63) - 1) * 2 + 1);
format_pico_time((power(2, 63) - 1) * 2 + 1)
213.50 d

SELECT format_pico_time(36000000.495523);
format_pico_time(36000000.495523)
36.00 us

SELECT format_pico_time(1000 * pow(10,12) * 86400);
format_pico_time(1000 * pow(10,12) * 86400)
1000.00 d

SELECT format_pico_time(86400000000000000000);
format_pico_time(86400000000000000000)
1000.00 d

SELECT format_pico_time(86400000000000000000+5000);
format_pico_time(86400000000000000000+5000)
1000.00 d

## Negative values are ok
SELECT format_pico_time(1010000 * -1);
format_pico_time(1010000 * -1)
-1.01 us

## Force exponent
SELECT format_pico_time(8650000000000000000099);
format_pico_time(8650000000000000000099)
1.00e+05 d

SELECT format_pico_time(-8650000000000000000099);
format_pico_time(-8650000000000000000099)
-1.00e+05 d

SELECT format_pico_time(8640000000000000000099 * 2);
format_pico_time(8640000000000000000099 * 2)
2.00e+05 d


## Text input
SELECT format_pico_time("foo");
format_pico_time("foo")
0 ps
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'foo'

SELECT format_pico_time("");
format_pico_time("")
0 ps
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: ''

SELECT format_pico_time("118059162071741143500099");
format_pico_time("118059162071741143500099")
1.37e+06 d

SELECT format_pico_time("-118059162071741143500099");
format_pico_time("-118059162071741143500099")
-1.37e+06 d

## Recognizes up to first non-numeric
SELECT format_pico_time("40000 * 2000");
format_pico_time("40000 * 2000")
40.00 ns
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '40000 * 2000'

SELECT format_pico_time("40000 foo 2000");
format_pico_time("40000 foo 2000")
40.00 ns
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '40000 foo 2000'
## Aggregate functions
USE test;

CREATE TABLE timer_waits (id VARCHAR(10), wait BIGINT UNSIGNED DEFAULT NULL) DEFAULT CHARSET = utf8mb4;

INSERT INTO timer_waits VALUES ('1 sec', 1000000000000);
INSERT INTO timer_waits VALUES ('1 min', 60000000000000);
INSERT INTO timer_waits VALUES ('1 hour', 3600000000000000);
INSERT INTO timer_waits VALUES ('1 day', 86400000000000000);
INSERT INTO timer_waits VALUES ('100 days', 8640000000000000000);

SELECT id, format_pico_time(wait), wait FROM timer_waits;
id format_pico_time(wait) wait
1 sec 1.00 s 1000000000000
1 min 1.00 min 60000000000000
1 hour 1.00 h 3600000000000000
1 day 1.00 d 86400000000000000
100 days 100.00 d 8640000000000000000

SELECT sum(wait), format_pico_time(sum(wait)) FROM timer_waits;
sum(wait) format_pico_time(sum(wait))
8730061000000000000 101.04 d

SELECT avg(wait), format_pico_time(avg(wait)) FROM timer_waits;
avg(wait) format_pico_time(avg(wait))
1746012200000000000.0000 20.21 d

SELECT min(wait), format_pico_time(min(wait)) FROM timer_waits;
min(wait) format_pico_time(min(wait))
1000000000000 1.00 s

SELECT max(wait), format_pico_time(max(wait)) FROM timer_waits;
max(wait) format_pico_time(max(wait))
8640000000000000000 100.00 d

DROP TABLE timer_waits;
## Using Scientific Notation
SELECT format_pico_time(3e9);
format_pico_time(3e9)
3.00 ms

SELECT format_pico_time(4e6);
format_pico_time(4e6)
4.00 us

SELECT format_pico_time(5e3);
format_pico_time(5e3)
5.00 ns

SELECT format_pico_time(6e2);
format_pico_time(6e2)
600 ps

0 comments on commit 2b61ff8

Please sign in to comment.