summaryrefslogtreecommitdiff
path: root/mysql-test/main/analyze_format_json_timings.result
blob: 4686359186e17ff0ed8dc25fa70d284f119c0d9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#
# MDEV-30830: ANALYZE FORMAT=JSON: r_unpack_time_ms is empty for the hashed joins
#
#
# First, check a regular BNL-join
#
create table t1 (
a int,
b int
);
insert into t1 select seq, seq/3 from seq_0_to_99;
create table t2 (
a int,
b int
);
insert into t2 select seq, seq/5 from seq_0_to_99;
set @js='$out';
set @out=(select json_extract(@js,'$**.block-nl-join.r_unpack_time_ms'));
select cast(json_extract(@out,'$[0]') as DOUBLE) > 0;
cast(json_extract(@out,'$[0]') as DOUBLE) > 0
1
drop table t1,t2;
#
# Now, check the hashed, BNL-H join
#
create table t1 (
a int,
b int
);
insert into t1 select seq, seq/3 from seq_0_to_499;
create table t2 (
a int,
b int
);
insert into t2 select seq, seq/5 from seq_0_to_499;
set @tmp=@@join_cache_level, join_cache_level=6;
select '$out' as X;
X
{
  "query_optimization": {
    "r_total_time_ms": "REPLACED"
  },
  "query_block": {
    "select_id": 1,
    "cost": "REPLACED",
    "r_loops": 1,
    "r_total_time_ms": "REPLACED",
    "nested_loop": [
      {
        "table": {
          "table_name": "t1",
          "access_type": "ALL",
          "loops": 1,
          "r_loops": 1,
          "rows": 500,
          "r_rows": 500,
          "cost": "REPLACED",
          "r_table_time_ms": "REPLACED",
          "r_other_time_ms": "REPLACED",
          "filtered": 100,
          "r_filtered": 100,
          "attached_condition": "t1.a < 700 and t1.b is not null"
        }
      },
      {
        "block-nl-join": {
          "table": {
            "table_name": "t2",
            "access_type": "hash_ALL",
            "key": "#hash#$hj",
            "key_length": "5",
            "used_key_parts": ["b"],
            "ref": ["test.t1.b"],
            "loops": 500,
            "r_loops": 1,
            "rows": 500,
            "r_rows": 500,
            "cost": "REPLACED",
            "r_table_time_ms": "REPLACED",
            "r_other_time_ms": "REPLACED",
            "filtered": 10,
            "r_filtered": 20,
            "attached_condition": "t2.a < 100"
          },
          "buffer_type": "flat",
          "buffer_size": "18Kb",
          "join_type": "BNLH",
          "attached_condition": "t2.b = t1.b",
          "r_loops": 500,
          "r_filtered": 100,
          "r_unpack_time_ms": "REPLACED",
          "r_other_time_ms": "REPLACED",
          "r_effective_rows": 0.594
        }
      }
    ]
  }
}
set @out=(select json_extract(@js,'$**.block-nl-join.r_unpack_time_ms'));
select cast(json_extract(@out,'$[0]') as DOUBLE) > 0;
cast(json_extract(@out,'$[0]') as DOUBLE) > 0
1
set join_cache_level=@tmp;
drop table t1, t2;
#
# MDEV-30972: ANALYZE FORMAT=JSON: some time is unaccounted-for in BNL-H join
#
create table t1 (
a int,
col1 varchar(100),
col2 varchar(100),
col3 varchar(100)
);
insert into t1 select
seq/100,
concat('col1-', seq),
concat('col1-', seq),
concat('col1-', seq)
from seq_1_to_1000;
create table t2 (
a int,
col1 varchar(100),
col2 varchar(100),
col3 varchar(100)
);
insert into t2 select
seq/100,
concat('col1-', seq),
concat('col1-', seq),
concat('col1-', seq)
from seq_1_to_2000;
set @tmp=@@join_cache_level, join_cache_level=6;
select '$out' as X;
X
{
  "query_optimization": {
    "r_total_time_ms": "REPLACED"
  },
  "query_block": {
    "select_id": 1,
    "cost": "REPLACED",
    "r_loops": 1,
    "r_total_time_ms": "REPLACED",
    "nested_loop": [
      {
        "table": {
          "table_name": "t1",
          "access_type": "ALL",
          "loops": 1,
          "r_loops": 1,
          "rows": 1000,
          "r_rows": 1000,
          "cost": "REPLACED",
          "r_table_time_ms": "REPLACED",
          "r_other_time_ms": "REPLACED",
          "filtered": 100,
          "r_filtered": 100,
          "attached_condition": "t1.a is not null"
        }
      },
      {
        "block-nl-join": {
          "table": {
            "table_name": "t2",
            "access_type": "hash_ALL",
            "key": "#hash#$hj",
            "key_length": "5",
            "used_key_parts": ["a"],
            "ref": ["test.t1.a"],
            "loops": 1000,
            "r_loops": 1,
            "rows": 2000,
            "r_rows": 2000,
            "cost": "REPLACED",
            "r_table_time_ms": "REPLACED",
            "r_other_time_ms": "REPLACED",
            "filtered": 10,
            "r_filtered": 100
          },
          "buffer_type": "flat",
          "buffer_size": "256Kb",
          "join_type": "BNLH",
          "attached_condition": "t2.a = t1.a and concat(t1.col1,t1.col2,t1.col3) = concat(t2.col1,t2.col2,t2.col3)",
          "r_loops": 1000,
          "r_filtered": 1.025630506,
          "r_unpack_time_ms": "REPLACED",
          "r_other_time_ms": "REPLACED",
          "r_effective_rows": 97.501
        }
      }
    ]
  }
}
set @out=(select json_extract(@js,'$**.block-nl-join.r_other_time_ms'));
select cast(json_extract(@out,'$[0]') as DOUBLE) > 0;
cast(json_extract(@out,'$[0]') as DOUBLE) > 0
1
set join_cache_level=@tmp;
drop table t1, t2;