Commit a8f6b86c authored by Monty's avatar Monty

Have ha_partition ignore HA_EXTRA..CHILDREN extra() calls if no myisamrg

MDEV-33502 Slowdown when running nested statement with many partitions

Optimization for tables with a lot of partitions
parent 71834ccb
...@@ -398,6 +398,7 @@ void ha_partition::init_handler_variables() ...@@ -398,6 +398,7 @@ void ha_partition::init_handler_variables()
m_start_key.length= 0; m_start_key.length= 0;
m_myisam= FALSE; m_myisam= FALSE;
m_innodb= FALSE; m_innodb= FALSE;
m_myisammrg= FALSE;
m_extra_cache= FALSE; m_extra_cache= FALSE;
m_extra_cache_size= 0; m_extra_cache_size= 0;
m_extra_prepare_for_update= FALSE; m_extra_prepare_for_update= FALSE;
...@@ -3030,6 +3031,10 @@ bool ha_partition::create_handlers(MEM_ROOT *mem_root) ...@@ -3030,6 +3031,10 @@ bool ha_partition::create_handlers(MEM_ROOT *mem_root)
DBUG_PRINT("info", ("InnoDB")); DBUG_PRINT("info", ("InnoDB"));
m_innodb= TRUE; m_innodb= TRUE;
} }
else if (ha_legacy_type(hton0) == DB_TYPE_MRG_MYISAM)
{
m_myisammrg= TRUE;
}
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }
...@@ -9419,9 +9424,14 @@ int ha_partition::extra(enum ha_extra_function operation) ...@@ -9419,9 +9424,14 @@ int ha_partition::extra(enum ha_extra_function operation)
} }
/* Category 9) Operations only used by MERGE */ /* Category 9) Operations only used by MERGE */
case HA_EXTRA_ADD_CHILDREN_LIST: case HA_EXTRA_ADD_CHILDREN_LIST:
if (!m_myisammrg)
DBUG_RETURN(0);
DBUG_RETURN(loop_partitions(extra_cb, &operation)); DBUG_RETURN(loop_partitions(extra_cb, &operation));
case HA_EXTRA_ATTACH_CHILDREN: case HA_EXTRA_ATTACH_CHILDREN:
{ {
if (!m_myisammrg)
DBUG_RETURN(0);
int result; int result;
uint num_locks; uint num_locks;
handler **file; handler **file;
...@@ -9440,8 +9450,9 @@ int ha_partition::extra(enum ha_extra_function operation) ...@@ -9440,8 +9450,9 @@ int ha_partition::extra(enum ha_extra_function operation)
break; break;
} }
case HA_EXTRA_IS_ATTACHED_CHILDREN: case HA_EXTRA_IS_ATTACHED_CHILDREN:
DBUG_RETURN(loop_partitions(extra_cb, &operation));
case HA_EXTRA_DETACH_CHILDREN: case HA_EXTRA_DETACH_CHILDREN:
if (!m_myisammrg)
DBUG_RETURN(0);
DBUG_RETURN(loop_partitions(extra_cb, &operation)); DBUG_RETURN(loop_partitions(extra_cb, &operation));
case HA_EXTRA_MARK_AS_LOG_TABLE: case HA_EXTRA_MARK_AS_LOG_TABLE:
/* /*
......
...@@ -399,6 +399,7 @@ class ha_partition final :public handler ...@@ -399,6 +399,7 @@ class ha_partition final :public handler
*/ */
bool m_innodb; // Are all underlying handlers bool m_innodb; // Are all underlying handlers
// InnoDB // InnoDB
bool m_myisammrg; // Are any of the handlers of type MERGE
/* /*
When calling extra(HA_EXTRA_CACHE) we do not pass this to the underlying When calling extra(HA_EXTRA_CACHE) we do not pass this to the underlying
handlers immediately. Instead we cache it and call the underlying handlers immediately. Instead we cache it and call the underlying
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment