After mysql_upgrade to 5.7, optimizer not using index on large IN clause Announcing the...
How to find out what spells would be useless to a blind NPC spellcaster?
Generate an RGB colour grid
Why do people hide their license plates in the EU?
What's the meaning of 間時肆拾貳 at a car parking sign
What to do with chalk when deepwater soloing?
What is Arya's weapon design?
Is there a (better) way to access $wpdb results?
Why am I getting the error "non-boolean type specified in a context where a condition is expected" for this request?
Selecting the same column from Different rows Based on Different Criteria
Dating a Former Employee
Why do we bend a book to keep it straight?
How to bypass password on Windows XP account?
Resolving to minmaj7
Coloring maths inside a tcolorbox
2001: A Space Odyssey's use of the song "Daisy Bell" (Bicycle Built for Two); life imitates art or vice-versa?
Why is "Consequences inflicted." not a sentence?
How does the particle を relate to the verb 行く in the structure「A を + B に行く」?
How come Sam didn't become Lord of Horn Hill?
A coin, having probability p of landing heads and probability of q=(1-p) of landing on heads.
3 doors, three guards, one stone
Can an alien society believe that their star system is the universe?
How to call a function with default parameter through a pointer to function that is the return of another function?
Can a USB port passively 'listen only'?
When do you get frequent flier miles - when you buy, or when you fly?
After mysql_upgrade to 5.7, optimizer not using index on large IN clause
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Slow complex query with group/ordermysql not using index on production query, yet does on staging and localShould I run mysql_upgrade after minor version upgrade via RPM?MySQL not using index on large WHERE IN clauseMysql query works on 5.5 but not on 5.7MySQL tuning: INNODB_BUFFER_POOL_SIZE not found?MySQL 5.7 UPDATE slow due to not using indexMariaDB query optimizer not using correct indexmySQL query optimizer not using indexes
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I have a similar issue to some other people have described.
- In MySQL 5.6.23-72.1-log, a query with a large number of values in an
IN
clause uses an index, and takes 10 minutes to run; - In 5.7.19-17 the same query does not use an index, and takes at least 2 (sometimes more than 4) hours.
I've tried
set session eq_range_index_dive_limit=4294967295
; no luck.
set @@global.max_seeks_for_key=100
; still no luck.
This happened after I upgraded some of the servers.
No issues were reported by mysql_upgrade.
As I noted, I've seen other questions, but none of the proposed answers there have resolved the situation for me.
Thanks very much to Rolando for his answers so far. I went ahead and tested with this in the [mysqld] section of my.cnf
optimizer_switch = index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,duplicateweedout=off,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=off,derived_merge=off
Alas the indexes are still not being picked up.
I tried with all the newly added options off:
duplicateweedout=off
condition_fanout_filter=off
derived_merge=off
I even tried with SET optimizer_switch='block_nested_loop=off'
because I was getting 'Using where; Using join buffer (Block Nested Loop)'
and 'Using temporary; Using filesort'
in my explain plan.
Still scratching my head. Thanks, The bottom line is the upgrade has caused a lot of queries to not use indexes and its a pain still. The database is almost 2TB but queries run fine in last few masters that are on 5.6
mysql mysql-5.6 migration upgrade mysql-5.7
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have a similar issue to some other people have described.
- In MySQL 5.6.23-72.1-log, a query with a large number of values in an
IN
clause uses an index, and takes 10 minutes to run; - In 5.7.19-17 the same query does not use an index, and takes at least 2 (sometimes more than 4) hours.
I've tried
set session eq_range_index_dive_limit=4294967295
; no luck.
set @@global.max_seeks_for_key=100
; still no luck.
This happened after I upgraded some of the servers.
No issues were reported by mysql_upgrade.
As I noted, I've seen other questions, but none of the proposed answers there have resolved the situation for me.
Thanks very much to Rolando for his answers so far. I went ahead and tested with this in the [mysqld] section of my.cnf
optimizer_switch = index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,duplicateweedout=off,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=off,derived_merge=off
Alas the indexes are still not being picked up.
I tried with all the newly added options off:
duplicateweedout=off
condition_fanout_filter=off
derived_merge=off
I even tried with SET optimizer_switch='block_nested_loop=off'
because I was getting 'Using where; Using join buffer (Block Nested Loop)'
and 'Using temporary; Using filesort'
in my explain plan.
Still scratching my head. Thanks, The bottom line is the upgrade has caused a lot of queries to not use indexes and its a pain still. The database is almost 2TB but queries run fine in last few masters that are on 5.6
mysql mysql-5.6 migration upgrade mysql-5.7
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Could you show some of the answers that haven't worked for you? Might give people some idea? You're saying that after an upgrade from 5.6.23 to 5.7.19, you're having difficulties with a query with a large number of values in anIN
clause? Can you turn these values into a table and do a join?
– Vérace
Dec 15 '17 at 23:42
add a comment |
I have a similar issue to some other people have described.
- In MySQL 5.6.23-72.1-log, a query with a large number of values in an
IN
clause uses an index, and takes 10 minutes to run; - In 5.7.19-17 the same query does not use an index, and takes at least 2 (sometimes more than 4) hours.
I've tried
set session eq_range_index_dive_limit=4294967295
; no luck.
set @@global.max_seeks_for_key=100
; still no luck.
This happened after I upgraded some of the servers.
No issues were reported by mysql_upgrade.
As I noted, I've seen other questions, but none of the proposed answers there have resolved the situation for me.
Thanks very much to Rolando for his answers so far. I went ahead and tested with this in the [mysqld] section of my.cnf
optimizer_switch = index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,duplicateweedout=off,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=off,derived_merge=off
Alas the indexes are still not being picked up.
I tried with all the newly added options off:
duplicateweedout=off
condition_fanout_filter=off
derived_merge=off
I even tried with SET optimizer_switch='block_nested_loop=off'
because I was getting 'Using where; Using join buffer (Block Nested Loop)'
and 'Using temporary; Using filesort'
in my explain plan.
Still scratching my head. Thanks, The bottom line is the upgrade has caused a lot of queries to not use indexes and its a pain still. The database is almost 2TB but queries run fine in last few masters that are on 5.6
mysql mysql-5.6 migration upgrade mysql-5.7
I have a similar issue to some other people have described.
- In MySQL 5.6.23-72.1-log, a query with a large number of values in an
IN
clause uses an index, and takes 10 minutes to run; - In 5.7.19-17 the same query does not use an index, and takes at least 2 (sometimes more than 4) hours.
I've tried
set session eq_range_index_dive_limit=4294967295
; no luck.
set @@global.max_seeks_for_key=100
; still no luck.
This happened after I upgraded some of the servers.
No issues were reported by mysql_upgrade.
As I noted, I've seen other questions, but none of the proposed answers there have resolved the situation for me.
Thanks very much to Rolando for his answers so far. I went ahead and tested with this in the [mysqld] section of my.cnf
optimizer_switch = index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,duplicateweedout=off,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=off,derived_merge=off
Alas the indexes are still not being picked up.
I tried with all the newly added options off:
duplicateweedout=off
condition_fanout_filter=off
derived_merge=off
I even tried with SET optimizer_switch='block_nested_loop=off'
because I was getting 'Using where; Using join buffer (Block Nested Loop)'
and 'Using temporary; Using filesort'
in my explain plan.
Still scratching my head. Thanks, The bottom line is the upgrade has caused a lot of queries to not use indexes and its a pain still. The database is almost 2TB but queries run fine in last few masters that are on 5.6
mysql mysql-5.6 migration upgrade mysql-5.7
mysql mysql-5.6 migration upgrade mysql-5.7
edited Jan 9 '18 at 22:33
jcolebrand♦
5,08843364
5,08843364
asked Dec 15 '17 at 19:52
StephenEStephenE
11
11
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 9 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Could you show some of the answers that haven't worked for you? Might give people some idea? You're saying that after an upgrade from 5.6.23 to 5.7.19, you're having difficulties with a query with a large number of values in anIN
clause? Can you turn these values into a table and do a join?
– Vérace
Dec 15 '17 at 23:42
add a comment |
Could you show some of the answers that haven't worked for you? Might give people some idea? You're saying that after an upgrade from 5.6.23 to 5.7.19, you're having difficulties with a query with a large number of values in anIN
clause? Can you turn these values into a table and do a join?
– Vérace
Dec 15 '17 at 23:42
Could you show some of the answers that haven't worked for you? Might give people some idea? You're saying that after an upgrade from 5.6.23 to 5.7.19, you're having difficulties with a query with a large number of values in an
IN
clause? Can you turn these values into a table and do a join?– Vérace
Dec 15 '17 at 23:42
Could you show some of the answers that haven't worked for you? Might give people some idea? You're saying that after an upgrade from 5.6.23 to 5.7.19, you're having difficulties with a query with a large number of values in an
IN
clause? Can you turn these values into a table and do a join?– Vérace
Dec 15 '17 at 23:42
add a comment |
1 Answer
1
active
oldest
votes
You may not be aware of this, but MySQL optimizer has a different setting between versions
For MySQL 5.6, optimizer_switch looks like this:
mysql> SELECT @@optimizer_switchG
*************************** 1. row ***************************
@@optimizer_switch: index_merge=on,index_merge_union=on,
index_merge_sort_union=on,
index_merge_intersection=on,
engine_condition_pushdown=on,
index_condition_pushdown=on,
mrr=on,mrr_cost_based=on,
block_nested_loop=on,batched_key_access=off,
materialization=on,semijoin=on,loosescan=on,
firstmatch=on,
subquery_materialization_cost_based=on,
use_index_extensions=on
For MySQL 5.7, optimizer_switch looks like this:
mysql> SELECT @@optimizer_switchG
*************************** 1. row ***************************
@@optimizer_switch: index_merge=on,index_merge_union=on,
index_merge_sort_union=on,
index_merge_intersection=on,
engine_condition_pushdown=on,
index_condition_pushdown=on,
mrr=on,mrr_cost_based=on,
block_nested_loop=on,batched_key_access=off,
materialization=on,semijoin=on,loosescan=on,
firstmatch=on,duplicateweedout=on,
subquery_materialization_cost_based=on,
use_index_extensions=on,
condition_fanout_filter=on,derived_merge=on
You could set the default for optimizer_switch for MySQL 5.6 in my.cnf
and restart MySQL 5.7. Then, the optimizer's behavior will be the same as before the upgrade. For the new options, set duplicateweedout=off
and derived_merge=off
.
This is not a complete answer. You'll have to test this.
Thanks very much Rolando. I added some new details to the question.
– StephenE
Jan 9 '18 at 19:34
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "182"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f193262%2fafter-mysql-upgrade-to-5-7-optimizer-not-using-index-on-large-in-clause%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You may not be aware of this, but MySQL optimizer has a different setting between versions
For MySQL 5.6, optimizer_switch looks like this:
mysql> SELECT @@optimizer_switchG
*************************** 1. row ***************************
@@optimizer_switch: index_merge=on,index_merge_union=on,
index_merge_sort_union=on,
index_merge_intersection=on,
engine_condition_pushdown=on,
index_condition_pushdown=on,
mrr=on,mrr_cost_based=on,
block_nested_loop=on,batched_key_access=off,
materialization=on,semijoin=on,loosescan=on,
firstmatch=on,
subquery_materialization_cost_based=on,
use_index_extensions=on
For MySQL 5.7, optimizer_switch looks like this:
mysql> SELECT @@optimizer_switchG
*************************** 1. row ***************************
@@optimizer_switch: index_merge=on,index_merge_union=on,
index_merge_sort_union=on,
index_merge_intersection=on,
engine_condition_pushdown=on,
index_condition_pushdown=on,
mrr=on,mrr_cost_based=on,
block_nested_loop=on,batched_key_access=off,
materialization=on,semijoin=on,loosescan=on,
firstmatch=on,duplicateweedout=on,
subquery_materialization_cost_based=on,
use_index_extensions=on,
condition_fanout_filter=on,derived_merge=on
You could set the default for optimizer_switch for MySQL 5.6 in my.cnf
and restart MySQL 5.7. Then, the optimizer's behavior will be the same as before the upgrade. For the new options, set duplicateweedout=off
and derived_merge=off
.
This is not a complete answer. You'll have to test this.
Thanks very much Rolando. I added some new details to the question.
– StephenE
Jan 9 '18 at 19:34
add a comment |
You may not be aware of this, but MySQL optimizer has a different setting between versions
For MySQL 5.6, optimizer_switch looks like this:
mysql> SELECT @@optimizer_switchG
*************************** 1. row ***************************
@@optimizer_switch: index_merge=on,index_merge_union=on,
index_merge_sort_union=on,
index_merge_intersection=on,
engine_condition_pushdown=on,
index_condition_pushdown=on,
mrr=on,mrr_cost_based=on,
block_nested_loop=on,batched_key_access=off,
materialization=on,semijoin=on,loosescan=on,
firstmatch=on,
subquery_materialization_cost_based=on,
use_index_extensions=on
For MySQL 5.7, optimizer_switch looks like this:
mysql> SELECT @@optimizer_switchG
*************************** 1. row ***************************
@@optimizer_switch: index_merge=on,index_merge_union=on,
index_merge_sort_union=on,
index_merge_intersection=on,
engine_condition_pushdown=on,
index_condition_pushdown=on,
mrr=on,mrr_cost_based=on,
block_nested_loop=on,batched_key_access=off,
materialization=on,semijoin=on,loosescan=on,
firstmatch=on,duplicateweedout=on,
subquery_materialization_cost_based=on,
use_index_extensions=on,
condition_fanout_filter=on,derived_merge=on
You could set the default for optimizer_switch for MySQL 5.6 in my.cnf
and restart MySQL 5.7. Then, the optimizer's behavior will be the same as before the upgrade. For the new options, set duplicateweedout=off
and derived_merge=off
.
This is not a complete answer. You'll have to test this.
Thanks very much Rolando. I added some new details to the question.
– StephenE
Jan 9 '18 at 19:34
add a comment |
You may not be aware of this, but MySQL optimizer has a different setting between versions
For MySQL 5.6, optimizer_switch looks like this:
mysql> SELECT @@optimizer_switchG
*************************** 1. row ***************************
@@optimizer_switch: index_merge=on,index_merge_union=on,
index_merge_sort_union=on,
index_merge_intersection=on,
engine_condition_pushdown=on,
index_condition_pushdown=on,
mrr=on,mrr_cost_based=on,
block_nested_loop=on,batched_key_access=off,
materialization=on,semijoin=on,loosescan=on,
firstmatch=on,
subquery_materialization_cost_based=on,
use_index_extensions=on
For MySQL 5.7, optimizer_switch looks like this:
mysql> SELECT @@optimizer_switchG
*************************** 1. row ***************************
@@optimizer_switch: index_merge=on,index_merge_union=on,
index_merge_sort_union=on,
index_merge_intersection=on,
engine_condition_pushdown=on,
index_condition_pushdown=on,
mrr=on,mrr_cost_based=on,
block_nested_loop=on,batched_key_access=off,
materialization=on,semijoin=on,loosescan=on,
firstmatch=on,duplicateweedout=on,
subquery_materialization_cost_based=on,
use_index_extensions=on,
condition_fanout_filter=on,derived_merge=on
You could set the default for optimizer_switch for MySQL 5.6 in my.cnf
and restart MySQL 5.7. Then, the optimizer's behavior will be the same as before the upgrade. For the new options, set duplicateweedout=off
and derived_merge=off
.
This is not a complete answer. You'll have to test this.
You may not be aware of this, but MySQL optimizer has a different setting between versions
For MySQL 5.6, optimizer_switch looks like this:
mysql> SELECT @@optimizer_switchG
*************************** 1. row ***************************
@@optimizer_switch: index_merge=on,index_merge_union=on,
index_merge_sort_union=on,
index_merge_intersection=on,
engine_condition_pushdown=on,
index_condition_pushdown=on,
mrr=on,mrr_cost_based=on,
block_nested_loop=on,batched_key_access=off,
materialization=on,semijoin=on,loosescan=on,
firstmatch=on,
subquery_materialization_cost_based=on,
use_index_extensions=on
For MySQL 5.7, optimizer_switch looks like this:
mysql> SELECT @@optimizer_switchG
*************************** 1. row ***************************
@@optimizer_switch: index_merge=on,index_merge_union=on,
index_merge_sort_union=on,
index_merge_intersection=on,
engine_condition_pushdown=on,
index_condition_pushdown=on,
mrr=on,mrr_cost_based=on,
block_nested_loop=on,batched_key_access=off,
materialization=on,semijoin=on,loosescan=on,
firstmatch=on,duplicateweedout=on,
subquery_materialization_cost_based=on,
use_index_extensions=on,
condition_fanout_filter=on,derived_merge=on
You could set the default for optimizer_switch for MySQL 5.6 in my.cnf
and restart MySQL 5.7. Then, the optimizer's behavior will be the same as before the upgrade. For the new options, set duplicateweedout=off
and derived_merge=off
.
This is not a complete answer. You'll have to test this.
answered Dec 16 '17 at 0:18
RolandoMySQLDBARolandoMySQLDBA
144k24228385
144k24228385
Thanks very much Rolando. I added some new details to the question.
– StephenE
Jan 9 '18 at 19:34
add a comment |
Thanks very much Rolando. I added some new details to the question.
– StephenE
Jan 9 '18 at 19:34
Thanks very much Rolando. I added some new details to the question.
– StephenE
Jan 9 '18 at 19:34
Thanks very much Rolando. I added some new details to the question.
– StephenE
Jan 9 '18 at 19:34
add a comment |
Thanks for contributing an answer to Database Administrators Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f193262%2fafter-mysql-upgrade-to-5-7-optimizer-not-using-index-on-large-in-clause%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Could you show some of the answers that haven't worked for you? Might give people some idea? You're saying that after an upgrade from 5.6.23 to 5.7.19, you're having difficulties with a query with a large number of values in an
IN
clause? Can you turn these values into a table and do a join?– Vérace
Dec 15 '17 at 23:42