• Alexander Nozdrin's avatar
    Cherry-picking a patch from Bug 12828477 from mysql-5.5 · 413fec98
    Alexander Nozdrin authored
    to mysql-5.5.16-release.
    
    Original revision:
    # revision-id: dmitry.lenev@oracle.com-20110811155849-feyt3h7tj48padiu
    # parent: tatjana.nuernberg@oracle.com-20110811120945-c6x9a5d2du8s9oj2
    # committer: Dmitry Lenev <Dmitry.Lenev@oracle.com>
    # branch nick: mysql-5.5-12828477
    # timestamp: Thu 2011-08-11 19:58:49 +0400
    # message:
    #   Fix for bug #12828477 - "MDL SUBSYSTEM CREATES BIG OVERHEAD 
    #   FOR CERTAIN QUERIES TO INFORMATION_SCHEMA".
    #   
    #   The problem was that metadata locking subsystem introduced
    #   too much overhead for queries to I_S which were processed by
    #   opening only .FRM or .TRG files and had to scanned a lot of
    #   tables (e.g. SELECT COUNT(*) FROM I_S.TRIGGERS was affected). 
    #   The same effect was not observed for similar queries which 
    #   performed full-blown table open in order to fill I_S table.
    #   
    #   The problem stemmed from the fact that in case when I_S 
    #   implementation opened only .FRM or .TRG file for each table 
    #   processed it didn't release metadata lock it has acquired on 
    #   the table after finishing its processing. As result, list
    #   of acquired metadata locks were growing until the end of 
    #   statement. Since acquisition of each new lock required 
    #   search in the list of already acquired locks performance
    #   degraded.
    #   
    #   The same effect is not observed when I_S implementation
    #   performs full-blown table open for each table being
    #   processed, as in the latter cases metadata lock on the
    #   table is released right after table processing.
    #   
    #   This fix addressed the problem by ensuring that I_S 
    #   implementation releases metadata lock after processing
    #   the table in both cases of full-blown table open and in 
    #   case when only .FRM or .TRG file is read.
    413fec98
sql_show.cc 276 KB