[MDEV-3453] LP:833777 - Performance regression with deeply nested subqueries Created: 2011-08-25 Updated: 2015-02-02 Resolved: 2012-10-04 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Philip Stoev (Inactive) | Assignee: | Timour Katchaounov (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | Launchpad | ||
| Attachments: |
|
| Description |
|
Monty reported that the following query, taken from the crash-me.sh script takes much longer in 5.3: select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me where a in (select a from crash_me)))))))))))))))))))))))))))))))) |
| Comments |
| Comment by Philip Stoev (Inactive) [ 2011-08-25 ] |
|
Re: Performance regression with deeply nested subqueries (16:13:57) montywi: spetrunia: the following query takes much longer in 5.3 than in 5.2: |
| Comment by Philip Stoev (Inactive) [ 2011-08-25 ] |
|
Re: Performance regression with deeply nested subqueries CREATE TABLE `crash_me` ( |
| Comment by Timour Katchaounov (Inactive) [ 2011-11-02 ] |
|
Re: Performance regression with deeply nested subqueries The optimizer distinguishes two kinds of 'constant' conditions: In order to avoid arbitrarily expensive optimization, the evaluation of Since in general there can be other conditions (e.g. ON, HAVING clauses), JOIN::exec() continue execution As a result, when an expensive constant condition is The result is that for subquries with depth N, JOIN::exec Solutions: |
| Comment by Sergei Petrunia [ 2011-11-03 ] |
|
Re: Performance regression with deeply nested subqueries SET @@optimizer_switch-'subquery_cache=off,semijoin=off' |
| Comment by Sergei Petrunia [ 2011-11-03 ] |
|
Re: Performance regression with deeply nested subqueries |
| Comment by Sergei Petrunia [ 2011-11-03 ] |
|
Re: Performance regression with deeply nested subqueries |
| Comment by Sergei Petrunia [ 2011-11-03 ] |
|
Re: Performance regression with deeply nested subqueries First execution happens in JOIN::exec: <code> if (zero_result_cause) { (void) return_zero_rows(this, result, select_lex->leaf_tables, *columns_list, send_row_on_empty_set(), select_options, zero_result_cause, having ? having : tmp_having); DBUG_VOID_RETURN; }</code> Note that: Second execution is done here: #0 do_select (join=0xbfa44c0, fields=0xbec2d3c, table=0x0, procedure=0x0) at sql_select.cc:14764 inside do_select(), we do: <code> else if (join->send_row_on_empty_set()) { ... } </code> Note that:
(join->table_count == join->const_tables) => join->exec_const_cond == join->conds and thus, the second check is redundant for non-EXPLAIN cases. |
| Comment by Rasmus Johansson (Inactive) [ 2011-11-21 ] |
|
Launchpad bug id: 833777 |