[MDEV-5976] TokuDB: Wrong query result using mrr=on Created: 2014-03-28 Updated: 2014-06-06 Resolved: 2014-06-06 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 10.0.9 |
| Fix Version/s: | 10.0.12 |
| Type: | Bug | Priority: | Critical |
| Reporter: | VAROQUI Stephane | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | tokudb | ||
| Attachments: |
|
| Description |
|
Compare to default settings we have join_cache_level = 6 This is the correct result : Without touching optimizer switch :
This is the wrong result with mrr=on
|
| Comments |
| Comment by Elena Stepanova [ 2014-03-28 ] | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Stephane, Please provide the data dump (upload it to the provide FTP if it shouldn't be published). Thanks. | |||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by VAROQUI Stephane [ 2014-04-01 ] | |||||||||||||||||||||||||||||||||||||||||||||||||
|
on the same dataset SELECT task_id, field,value FROM ym_tasks_options WHERE task_id IN ( SELECT task_id FROM ym_tasks WHERE type IN (99,10,2,3,4,6,9,1,7,5) Does not produce same number of rows | |||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2014-06-03 ] | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Repeatable.
SELECT produces two rows. Now, if I do
and re-run the query:
SELECT produces 78 rows. (with join_cache_level=0 I also get 78 rows so I assume that's the correct | |||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2014-06-04 ] | |||||||||||||||||||||||||||||||||||||||||||||||||
|
The problem is not related to subqueries. The optimizer rewrites the subquery into join. Here is a join query that shows the same result set difference, depending on the value of mrr_sort_keys:
| |||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2014-06-04 ] | |||||||||||||||||||||||||||||||||||||||||||||||||
|
"ORDER BY task_id" is also irrelevant. | |||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2014-06-06 ] | |||||||||||||||||||||||||||||||||||||||||||||||||
|
OK, let's switch to exploring the join query. The query plan that produces the wrong result is:
| |||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2014-06-06 ] | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Let's explore the dataset
There are two lookup keys, 1 and 2. Each has 39 matches. We should get 2*39= 78 rows. However, we only get two. | |||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2014-06-06 ] | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Debugging Breakpoint 8, handler::ha_index_read_map (this=0x7fffb9a9e088, buf=0x7fffb988b088 "\377", key=0x7fffb9aa1072 "\001", keypart_map=1, find_flag=HA_READ_KEY_EXACT) at /home/psergey/dev2/10.0/sql/handler.cc:2580 Breakpoint 15, handler::ha_index_next_same (this=0x7fffb9a9e088, buf=0x7fffb988b088 "\377\001", key=0x7fffb9ac1050 "r\020\252\271\377\177", keylen=4) at /home/psergey/dev2/10.0/sql/handler.cc:2690 (gdb) x/4c key ^^ This is HA_ERR_END_OF_FILE, and it is already incorrect. First guess at the cause of the problem: why isthe parameter key=0x7fffb9ac1050 "r\020\252\271\377\177" ? We're doing lookup on 0x01 0x00 0x00 0x00... | |||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2014-06-06 ] | |||||||||||||||||||||||||||||||||||||||||||||||||
|
the parameter is actually a pointer to pointer to the key value. | |||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2014-06-06 ] | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Pushed to 10.0 tree |