Commit graph

140 commits

Author SHA1 Message Date
Alexey Botchkov
e9fd327ee3 MDEV-17399 Add support for JSON_TABLE.
The specific table handler for the table functions was introduced,
and used to implement JSON_TABLE.
2021-04-21 10:21:43 +04:00
Sergei Petrunia
2656e87682 Cleanup: fake_select_lex->select_number=FAKE_SELECT_LEX_ID, not [U]INT_MAX
SELECT_LEX objects that are "fake_select_lex" (i.e read UNION output)
used both INT_MAX and UINT_MAX as select_number.
- mysql_explain_union() assigned UINT_MAX
- st_select_lex_unit::add_fake_select_lex assigned INT_MAX

This didn't matter initially (before EXPLAIN FORMAT=JSON), because the
code  had no checks for this value.

EXPLAIN FORMAT=JSON and later other features did introduce checks for
select_number values. The check had to check for two constants and
looked really confusing.

This patch joins the two constants into one - FAKE_SELECT_LEX_ID.
2021-04-17 00:05:29 +03:00
Marko Mäkelä
b30a013142 Merge 10.4 into 10.5 2020-05-13 14:25:06 +03:00
Marko Mäkelä
38f6c47f8a Merge 10.3 into 10.4 2020-05-13 12:52:57 +03:00
Sergei Petrunia
d01d94d77b MDEV-17568: LATERAL DERIVED is not clearly visible in EXPLAIN FORMAT=JSON
Make LATERAL DERIVED tables visible in EXPLAIN FORMAT=JSON output.
2020-05-06 23:44:34 +03:00
Sergei Golubchik
7c58e97bf6 perfschema memory related instrumentation changes 2020-03-10 19:24:22 +01:00
Sergei Petrunia
68ed3a81f2 MDEV-20854: ANALYZE for statements: not clear where the time is spent
Count the "gap" time between table accesses and display it as
r_other_time_ms in the "table" element.

* The advantage of this approach is that it doesn't add any new
  my_timer_cycles() calls.
* The disadvantage is that the definition of what is done during
  "other time" is not that clear: it includes checking the WHERE
  (for this table), constructing index lookup tuple (for the next table)
  writing to GROUP BY temporary table (as we dont account for that time
  separately [yet], etc)
2019-11-12 14:40:00 +03:00
Marko Mäkelä
2fd82471ab Merge 10.3 into 10.4 2019-06-12 08:37:27 +03:00
Marko Mäkelä
b42dbdbccd Merge 10.2 into 10.3 2019-06-11 13:00:18 +03:00
Sergei Petrunia
5d06edfb26 MDEV-19714: JOIN::pseudo_bits_cond is not visible in EXPLAIN FORMAT=JSON
Make it visible
2019-06-08 02:28:29 +03:00
Oleksandr Byelkin
c07325f932 Merge branch '10.3' into 10.4 2019-05-19 20:55:37 +02:00
Marko Mäkelä
be85d3e61b Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
Marko Mäkelä
26a14ee130 Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
Vicențiu Ciorbaru
cb248f8806 Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
Igor Babaev
98d55b1366 Merge branch '10.4' into bb-10.4-mdev16188 2019-02-14 22:07:33 -08:00
Igor Babaev
16327fc2e7 MDEV-17096 Pushdown of simple derived tables to storage engines
MDEV-17631 select_handler for a full query pushdown

Interfaces + Proof of Concept for federatedx with test cases.

The interfaces have been developed for integration of ColumnStore engine.
2019-02-06 17:02:44 -08:00
Galina Shalygina
447e0f023f MDEV-18144: ANALYZE for statement support for PK filters
ANALYZE and ANALYZE FORMAT=JSON structures are changed in the way that they
show additional information when rowid filter is used:

- r_selectivity_pct - the observed filter selectivity
- r_buffer_size - the size of the rowid filter container buffer
- r_filling_time_ms - how long it took to fill rowid filter container

New class Rowid_filter_tracker was added. This class is needed to collect data
about how rowid filter is executed.
2019-02-06 23:40:07 +03:00
Igor Babaev
658128af43 MDEV-16188 Use in-memory PK filters built from range index scans
This patch contains a full implementation of the optimization
that allows to use in-memory rowid / primary filters built for range  
conditions over indexes. In many cases usage of such filters reduce  
the number of disk seeks spent for fetching table rows.

In this implementation the choice of what possible filter to be applied  
(if any) is made purely on cost-based considerations.

This implementation re-achitectured the partial implementation of
the feature pushed by Galina Shalygina in the commit
8d5a11122c.

Besides this patch contains a better implementation of the generic  
handler function handler::multi_range_read_info_const() that
takes into account gaps between ranges when calculating the cost of
range index scans. It also contains some corrections of the
implementation of the handler function records_in_range() for MyISAM.

This patch supports the feature for InnoDB and MyISAM.
2019-02-03 14:56:12 -08:00
Galina Shalygina
8d5a11122c MDEV-16188: Use in-memory PK filters built from range index scans
First phase: make optimizer choose to use filter and show it in EXPLAIN.
2018-09-28 23:50:22 +03:00
Marko Mäkelä
b006d2ead4 Merge bb-10.2-ext into 10.3 2018-02-15 10:22:03 +02:00
Alexander Barkov
3cad31f2a7 Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2018-02-08 19:06:25 +04:00
Sergei Golubchik
4771ae4b22 Merge branch 'github/10.1' into 10.2 2018-02-06 14:50:50 +01:00
Oleksandr Byelkin
80d3eee072 MDEV-14857: problem with 10.2.11 server crashing when executing stored procedure
Counter for select numbering made stored with the statement (before was global)
So now it does have always accurate value which does not depend on
interruption of statement prepare by errors like lack of table in
a view definition.
2018-02-01 09:51:47 +01:00
Marko Mäkelä
145ae15a33 Merge bb-10.2-ext into 10.3 2018-01-04 09:22:59 +02:00
Monty
fbab79c9b8 Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext
Conflicts:
	cmake/make_dist.cmake.in
	mysql-test/r/func_json.result
	mysql-test/r/ps.result
	mysql-test/t/func_json.test
	mysql-test/t/ps.test
	sql/item_cmpfunc.h
2018-01-01 19:39:59 +02:00
Varun Gupta
a118c20c81 MDEV-10844: EXPLAIN FORMAT=JSON doesn't show order direction for filesort
Currently explain format=json does not show the order direction of fields used during filesort.
This patch would remove this limitation
2017-12-30 10:18:22 +05:30
Michael Widenius
87933d5261 Handle failures from malloc
Most "new" failures fixed in the following files:
- sql_select.cc
- item.cc
- item_func.cc
- opt_subselect.cc

Other things:
- Allocate udf_handler strings in mem_root
  - Required changes in sql_string.h
- Add mem_root as argument to some new [] calls
- Mark udf_handler strings as thread specific
- Removed some comment blocks with code
2017-11-17 07:30:05 +02:00
Alexander Barkov
f00a314f9a Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-03-31 16:40:29 +04:00
Sergei Golubchik
da4d71d10d Merge branch '10.1' into 10.2 2017-03-30 12:48:42 +02:00
Oleksandr Byelkin
05d3c3d3f7 MDEV-10141: Add support for INTERSECT (and common parts for EXCEPT)
MDEV-10140: Add support for EXCEPT
2017-03-14 11:52:00 +01:00
iangilfillan
f0ec34002a Correct FSF address 2017-03-10 18:21:29 +01:00
Sergei Petrunia
a2f245e49f MDEV-10372: EXPLAIN fixes for recursive CTEs, including FORMAT=JSON
- Tabular EXPLAIN now prints "RECURSIVE UNION".
- There is a basic implementation of EXPLAIN FORMAT=JSON.
- it produces "recursive_union" JSON struct
- No other details or ANALYZE support, yet.
2016-08-08 23:02:52 +03:00
Galina Shalygina
be1d06c8a5 Merge branch '10.2' into 10.2-mdev9864 2016-05-08 23:04:41 +03:00
Sergei Petrunia
ab44e892d8 MDEV-9652: EXPLAIN FORMAT=JSON should show outer_ref_cond
Show outer_ref_condition in EXPLAIN FORMAT=JSON output.
2016-02-28 18:18:29 +03:00
Sergei Petrunia
7016621596 MDEV-8829: Assertion `0' failed in Explain_table_access::tag_to_json
- Add EXPLAIN/ANALYZE FORMAT=JSON handling for a few special cases.
2015-09-24 15:45:54 +03:00
Oleksandr Byelkin
da3ec3d421 MDEV-7970: EXPLAIN FORMAT=JSON does not print HAVING
Printing non-trivial HAVING added.
2015-09-18 16:08:13 +02:00
Sergei Petrunia
3025c42605 Make ANALYZE FORMAT=JSON show execution time for filesort element. 2015-08-07 17:41:35 +03:00
Sergei Petrunia
9d2aa2b309 MDEV-7811: EXPLAIN/ANALYZE FORMAT=JSON should show subquery cache
Fixes over the original patch:
- Fix variable/class/other names
- Fix the JSON output to be in line with the output of other JSON
  constructs we produce
2015-07-01 20:03:29 +03:00
Oleksandr Byelkin
c6aee27b73 MDEV-7811: EXPLAIN/ANALYZE FORMAT=JSON should show subquery cache 2015-06-30 23:07:14 +03:00
Sergei Petrunia
93fc04ff1d MDEV-6995: EXPLAIN JSON and ORDER BY, GROUP BY, etc
- Make ANALYZE correctly remember and report filesort() calls
- Temp.table use is collected but only basic info is reported.
2015-06-06 00:32:27 +03:00
Sergei Petrunia
0719df781e Merge 2015-04-12 04:59:34 +03:00
Sergei Petrunia
4938b82263 MDEV-7836: ANALYZE FORMAT=JSON should provide info about GROUP/ORDER BY
Provide basic info about sorting/grouping done by the queries.
2015-04-12 04:48:42 +03:00
Oleksandr Byelkin
b05383cb14 MDEV-7835: ANALYZE FORMAT=JSON should show buffer sizes 2015-04-09 14:51:23 +02:00
Oleksandr Byelkin
697194461a MDEV-7856: EXPLAIN FORMAT=JSON should show partitions 2015-04-09 14:21:02 +02:00
Sergei Petrunia
2af935c8ec MDEV-7899: 10.1 is 3% slower than 10.0 in OLTP RO
- Remove ANALYZE's timing code off the the execution path of regular
  SELECTs.
- Improve the tracker that tracks counts/execution times of SELECTs or
  DML statements:
  = regular execution just increments counters
  = ANALYZE will also collect timings.
2015-04-07 01:29:17 +03:00
Sergei Petrunia
2936fb127d MDEV-7919: main.explain_json* fail in buildbot with valgrind
Correctly initialize Explain_node::connection_type, remove unused
Explain_node constructor.
2015-04-06 18:54:08 +03:00
Oleksandr Byelkin
a220905083 MDEV-7833:ANALYZE FORMAT=JSON and Range checked for each record 2015-04-03 15:37:27 +02:00
Oleksandr Byelkin
b2a1187307 MDEV-7812: ANALYZE FORMAT=JSON UPDATE/DELETE doesnt print the r_total_time_ms
Tracking total time added in UPDATE/DELETE
Fixed selectivity calculation in UPDATE/DELETE
Macro definitions of time tracting fixed.
2015-03-29 15:33:15 +02:00
Sergei Petrunia
664ce4c507 Fix linking: move the inline functions 2015-03-24 17:35:29 +03:00
Sergei Petrunia
77e16ce7d6 MDEV-7648: Extra data in ANALYZE FORMAT=JSON $stmt
Switch from relying on PERFORMANCE_SCHEMA to using our
own hooks for counting the time spent reading rows from
tables.
2015-03-24 16:17:41 +03:00
Sergei Petrunia
b273e4a5c0 Better comments 2015-03-24 13:22:03 +03:00
Sergei Petrunia
1626e0d3d4 MDEV-7648: Extra data in ANALYZE FORMAT=JSON $stmt
Show total execution time (r_total_time_ms) for various parts of the
query:
1. time spent in SELECTs
2. time spent reading rows from storage engines

#2 currently gets the data from P_S.
2015-03-07 22:47:28 +03:00
Sergei Petrunia
66ad265f3b MDEV-7674: ANALYZE shows r_rows=0
Change r_rows to be double
2015-03-07 19:30:19 +03:00
Sergei Petrunia
dc259324d7 EXPLAIN JSON: Print out the "expensive constant condition" attached to joins. 2014-12-06 19:27:42 +03:00
Sergei Petrunia
5ee1c25fa8 EXPLAIN FORMAT=JSON: Full scan on NULL key (join case) 2014-12-06 03:11:03 +03:00
Sergei Petrunia
a80a797686 EXPLAIN FORMAT=JSON: Support "range checked for each record" 2014-12-06 02:23:37 +03:00
Sergei Petrunia
9cac7649ea EXPLAIN FORMAT=JSON: Support range+MRR plans (when MRR is used but BKA is not) 2014-12-06 01:11:22 +03:00
Monty
78564373fe my_alloc.c
- Changed 0x%lx -> %p
array.c:
- Static (preallocated) buffer can now be anywhere
my_sys.h
- Define MY_INIT_BUFFER_USED
sql_delete.cc & sql_lex.cc
- Use memroot when allocating classes (avoids call to current_thd)
sql_explain.h:
- Use preallocated buffers
sql_explain.cc:
- Use preallocated buffers and memroot
sql_select.cc:
- Use multi_alloc_root() instead of many alloc_root()
- Update calls to Explain
2014-12-05 11:01:51 +04:00
Sergei Petrunia
0000695025 EXPLAIN FORMAT=JSON
Add support for semi-join strategies: FirstMatch, DuplicateWeedout,
LooseScan.
2014-12-02 01:40:10 +03:00
Sergei Petrunia
753718c201 EXPLAIN FORMAT=JSON: support SJ-Materialization
- Switch Explain data structure from "flat" representation of
  SJ-Materialization into nested one.
- Update functions that print tabular output to operate on the
  nested structure.
- Add function to generate JSON output.
2014-12-01 21:35:31 +03:00
Sergei Petrunia
c46eadb2b3 EXPLAIN FORMAT=JSON: support EXPLAIN FORMAT=JSON INSERT ... 2014-11-29 03:28:46 +03:00
Sergei Petrunia
e235bb864d ANALYZE FORMAT=JSON: better output and tests
- Print r_loops
- Always print r_* members. Print NULL values if no scans took place
- Added testcases.
2014-11-29 03:07:24 +03:00
Sergei Petrunia
0b5d989c89 EXPLAIN FORMAT=JSON: Add support for non-merged semi-joins 2014-11-29 01:08:18 +03:00
Sergei Petrunia
2ac3b39e68 EXPLAIN FORMAT=JSON: support derived tables 2014-11-28 22:23:29 +03:00
Sergei Petrunia
d5fbfb9a93 EXPLAIN FORMAT=JSON: Add support for single-table UPDATE/DELETE. 2014-11-28 02:36:31 +03:00
Sergei Petrunia
461dbd80d2 EXPLAIN FORMAT=JSON: support join buffering
- Basic support for JOIN buffering
- The output is not polished but catches the main point:
  tab->select_cond and tab->cache_select->cond are printed separately.
- Hash join support is poor still.

- Also fixed identation in JOIN_TAB::save_explain_data
2014-11-27 23:10:44 +03:00
Sergei Petrunia
37c444e1a0 EXPLAIN FORMAT=JSON: further development
Writing JSON:
- Fix a bug in Single_line_formatting_helper
- Add Json_writer_nesting_guard - safety class

EXPLAIN JSON support
- Add basic subquery support
- Add tests for UNION/UNION ALL.
2014-11-27 19:32:48 +03:00
Sergei Petrunia
3d5f97fd70 Merge ../10.1-explain-json-r4 into 10.1 2014-11-27 00:51:54 +03:00
Igor Babaev
3c4bb0e872 MDEV-334: Backport of UNION ALL optimization from mysql-5.7.
Although the original code of mysql-5.7 was adjusted
to the current MariaDB code the main ideas of the optimization
were preserved.
2014-10-14 09:36:50 -07:00
Sergei Petrunia
041e03e251 EXPLAIN FORMAT=JSON: produce used_key_parts, JSON-ish output for index_merge. 2014-08-14 01:12:05 +04:00
Sergei Petrunia
a9d43d70f5 EXPLAIN FORMAT=JSON: produce the 'ref' column. 2014-08-12 18:14:56 +04:00
Sergei Petrunia
83f0ddc629 Merge 10.1 (with ANALYZE) and 10.1-explain-json 2014-08-09 01:52:54 +04:00
Sergei Petrunia
c6be74458f MDEV-6398: ANALYZE UPDATE does not populate r_rows
- In print_explain_row(), do not forget to print r_rows.
- Switch Explain_update from using its own counters to re-using
  Table_access_tracker.
- Make ANALYZE UPDATE code structure uniform with ANALYZE DELETE.
2014-06-26 19:09:23 +04:00
Sergei Petrunia
7711999d8b MDEV-406: ANALYZE $stmt: add support for BNL join buffering 2014-06-25 15:15:38 +04:00
Sergei Petrunia
c3cfb6910a MDEV-406: ANALYZE $stmt: Scans that never executed will have r_rows=NULL 2014-06-24 23:58:13 +04:00
Sergei Petrunia
06a87d77e6 Fix compile on Windows: use rint() instead of round(). 2014-06-24 23:38:49 +04:00
Sergei Petrunia
c08de06246 MDEV-406: ANALYZE $stmt: get ANALYZE work for subqueries
- "ANALYZE $stmt" should discard select's output, but it should still
  evaluate the output columns (otherwise, subqueries in select list
  are not executed)
- SHOW EXPLAIN's code practice of calling JOIN::save_explain_data()
  after JOIN::exec() is disastrous for ANALYZE, because it resets
  all counters after the first execution. It is stopped
  = "Late" test_if_skip_sort_order() calls explicitly update their part
    of the query plan.
  = Also, I had to rewrite I_S optimization to actually have optimization
    and execution stages.
2014-06-24 19:41:43 +04:00
Sergei Petrunia
917b22393f MDEV-406: ANALYZE $stmt
- Testcase for ANALYZE UNION
- Provide r_rows for union result.
2014-06-03 19:04:59 +04:00
Sergei Petrunia
5621aa3230 MDEV-406: ANALYZE $stmt
- Support tracking for UNIONs, temporary-table based ORDER BYs,
  and both.
2014-06-03 17:59:01 +04:00
Sergei Petrunia
5cfd3270ec MDEV-6109: EXPLAIN JSON
- First code, "EXPLAIN FORMAT=JSON stmt" and "ANALYZE FORMAT=JSON stmt"
  work for basic queries.  Complex constructs (e.g subqueries, etc) not
  yet supported.
- No test infrastructure yet
2014-05-27 21:04:45 +04:00
Sergei Petrunia
eaba1ba4a5 Re-commit in git:
MDEV-406: ANALYZE $stmt
- Ported the old patch to new explain code
- New SQL syntax (ANALYZE $stmt)
- ANALYZE UPDATE/DELETE is now supported (because EXPLAIN UPDATE/DELETE is supported)
- Basic counters are calculated for basic kinds of queries
  (still need to see what happens with join buffer, ORDER BY...LIMIT queries, etc)
2014-05-27 20:13:17 +04:00
Sergey Petrunya
651b924912 Better comments 2013-10-17 17:50:30 +04:00
Sergey Petrunya
e62e1e8a3b Better comments 2013-10-16 12:16:10 +04:00
Sergey Petrunya
105e3ae6c9 MDEV-3798: EXPLAIN UPDATE/DELETE
Update the SHOW EXPLAIN code to work with the 
new architecture (part#1):
Before, SHOW EXPLAIN operated on real query plan structures, 
which meant it had to check when SELECTs are created/deleted.
SELECTs would call apc_target->enable() when they got a query 
plan and disable() when their query plan was deleted.

Now, Explain data structure becomes available at once (and we
call apc_target->enable()) and then it stays until it is deleted
(when that happens, we call apc_target->disable()).
2013-10-14 20:09:33 +04:00
Sergey Petrunya
161d687594 MDEV-3798: EXPLAIN UPDATE/DELETE
- Generate correct contents of `Extra` column for UPDATEs/DELETEs that use quick selects
- UPDATEs with used_key_is_modified=true will show "Using buffer"
2013-10-09 09:40:33 +04:00
Sergey Petrunya
98a8642fe8 MDEV-3798: EXPLAIN UPDATE/DELETE
- Add support for EXPLAIN INSERT.
2013-10-07 17:29:51 +04:00
Sergey Petrunya
69393db3d1 MDEV-3798: EXPLAIN UPDATE/DELETE
- Better EXPLAIN-saving methods for quick selects
2013-10-07 13:58:47 +04:00
Sergey Petrunya
abcf14e595 MDEV-3798: EXPLAIN UPDATE/DELETE
- Handle the case when EXPLAIN UPDATE/DELETE has pruned away all partitions.
2013-10-05 13:44:01 +04:00
Sergey Petrunya
72bc6d7364 MDEV-3798: EXPLAIN UPDATE/DELETE
- Address review feedback: more renames
2013-10-05 13:19:45 +04:00
Sergey Petrunya
6a7f8af3f9 MDEV-3798: EXPLAIN UPDATE/DELETE
- Address review feedback: rename files
2013-10-05 10:25:59 +04:00
Renamed from sql/opt_qpf.h (Browse further)