diff options
author | Jacob Mathew <jacob.mathew@mariadb.com> | 2017-03-03 16:36:00 -0800 |
---|---|---|
committer | Jacob Mathew <jacob.mathew@mariadb.com> | 2017-03-03 16:36:00 -0800 |
commit | 6080b610c61dd39f0b685544beac3d6a67223152 (patch) | |
tree | 651de07d3b0523b8235eb2c9b0cb6b78cb499cbf /storage/spider/spd_db_mysql.cc | |
parent | 554c60ab0d383e8e6d473294fb86a9db0b0d2b9b (diff) | |
download | mariadb-git-MDEV-8954.tar.gz |
Changes to fix Spider Performance Bug MDEV-8954 in 10.1MDEV-8954
Diffstat (limited to 'storage/spider/spd_db_mysql.cc')
-rw-r--r-- | storage/spider/spd_db_mysql.cc | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 3f56d9a9d89..f33c4672969 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -9516,6 +9516,65 @@ int spider_mysql_handler::append_explain_select( DBUG_RETURN(0); } +/******************************************************************** + * Determine whether the current query's projection list + * consists solely of the specified column. + * + * Params IN - field_index: + * Field index of the column of interest within + * its table. + * + * Returns TRUE - if the query's projection list consists + * solely of the specified column. + * FALSE - otherwise. + ********************************************************************/ +bool spider_mysql_handler::is_sole_projection_field( uint16 field_index ) +{ + // Determine whether the projection list consists solely of the field of interest + bool is_field_in_projection_list = FALSE; + TABLE* table = spider->get_table(); + uint16 projection_field_count = 0; + uint16 projection_field_index; + Field** field; + DBUG_ENTER( "spider_mysql_handler::is_sole_projection_field" ); + + for ( field = table->field; *field ; field++ ) + { + projection_field_index = ( *field )->field_index; + + if ( !( minimum_select_bit_is_set( projection_field_index ) ) ) + { + // Current field is not in the projection list + continue; + } + + projection_field_count++; + + if ( !is_field_in_projection_list ) + { + if ( field_index == projection_field_index ) + { + // Field of interest is in the projection list + is_field_in_projection_list = TRUE; + } + } + + if ( is_field_in_projection_list && ( projection_field_count != 1 ) ) + { + // Field of interest is not the sole column in the projection list + DBUG_RETURN( FALSE ); + } + } + + if ( is_field_in_projection_list && ( projection_field_count == 1 ) ) + { + // Field of interest is the only column in the projection list + DBUG_RETURN( TRUE ); + } + + DBUG_RETURN( FALSE ); +} + bool spider_mysql_handler::is_bulk_insert_exec_period( bool bulk_end ) { |