[MDEV-3685] LP:983423 - Different execution plans for subquery Created: 2012-04-16 Updated: 2012-10-04 Resolved: 2012-10-04 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | ||
| Reporter: | jason clifton (Inactive) | Assignee: | Timour Katchaounov (Inactive) |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | Launchpad | ||
| Attachments: |
|
| Description |
|
I'm not sure this is actually a bug or expected behavior.... SELECT SUM(`PAIDAMT`) as total, SUM(`DISCOUNT`) as discount from `ap_invoices` WHERE `VENDNO`='UPS' AND `INVNO` IN(SELECT `INVNO` FROM `checks_written` WHERE `CHECKNO`='42356') I get the following explain extended -----
-----
----- However if I remove the single quote marks from CHECKNO so the query looks like I get an explain that looks like -----
-----
----- table structures CREATE TABLE `ap_invoices` ( – CREATE TABLE `checks_written` ( |
| Comments |
| Comment by Elena Stepanova [ 2012-04-17 ] | ||||||||||||||||||||||||||||||||||||||||
|
Re: Different execution plans for subquery What is the actual problem? Is it just the observation that the plans are different (which of course can happen), or is one of the plans badly inefficient, so the query is executed too slowly? If so, which one is it and how slow it gets (comparing to the other one)? Thank you. | ||||||||||||||||||||||||||||||||||||||||
| Comment by jason clifton (Inactive) [ 2012-04-17 ] | ||||||||||||||||||||||||||||||||||||||||
|
Re: Different execution plans for subquery | ||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2012-04-17 ] | ||||||||||||||||||||||||||||||||||||||||
|
Re: Different execution plans for subquery | ||||||||||||||||||||||||||||||||||||||||
| Comment by Timour Katchaounov (Inactive) [ 2012-04-18 ] | ||||||||||||||||||||||||||||||||||||||||
|
Re: Different execution plans for subquery `CHECKNO`='42356' vs `CHECKNO`=42356 In the second case a numeric constant is implicitly converted to a string. This is not a bug. AFAIK for instance Oracle has the same behavior Try the following simple example: If we supply a string constant of the same length, then the index is used: explain select * from t1 where '1' = c1;
-----
----- However, if the constant needs to be converted implicitly, the index cannot be used explain select * from t1 where 1 = c1;
-----
----- | ||||||||||||||||||||||||||||||||||||||||
| Comment by Rasmus Johansson (Inactive) [ 2012-04-18 ] | ||||||||||||||||||||||||||||||||||||||||
|
Launchpad bug id: 983423 |