Database Research & Development

  • Home
  • NoSQL
    • NoSQL
    • Cassandra
  • Databases
    • Database Theory
    • Database Designing
    • SQL Server Coding Standards
    • SQL Server
    • PostgreSQL
    • MySQL
    • Greenplum
    • Linux
  • Interviews
    • SQL Server Interviews
    • MySQL Interviews
    • SQL Puzzles
  • DBA Scripts
    • SQL Server DBA Scripts
    • PostgreSQL DBA Scripts
    • MySQL DBA Scripts
    • Greenplum DBA Scripts
  • Home
  • Blog Archives !
  • (: Laugh@dbrnd :)
  • Contact Me !
sqlserverinterviews
Home 2016 October MySQL 5.7: Script to find list of Active InnoDB Temp Tables using INNODB_TEMP_TABLE_INFO

MySQL 5.7: Script to find list of Active InnoDB Temp Tables using INNODB_TEMP_TABLE_INFO

This article is half-done without your Comment! *** Please share your thoughts via Comment ***

MySQL 5.7 introduced INNODB_TEMP_TABLE_INFO table added into INFORMATION_SCHEMA.

Using INNODB_TEMP_TABLE_INFO, you can get A list of all active Temp Table of MySQL InnoDB Instance.
You can get the information of all active user created and system created Temp Tables.

The Database Administrator can use this script for monitoring total Temp Table in MySQL Server.
Unnecessarily, we should not create a TEMP Table because It requires temporary disk + memory storage and degrade the overall performance of MySQL Server.

Once you get the list of tables using INNODB_TEMP_TABLE_INFO, you can get system generated Temp Table Name.

Check existance of INNODB_TEMP_TABLE_INFO:

1
SHOW TABLES FROM INFORMATION_SCHEMA LIKE 'INNODB_TEMP%';

Create two sample Temporary Table:

1
2
CREATE TEMPORARY TABLE ABC (ID INT, Name VARCHAR(50));
CREATE TEMPORARY TABLE XYZ (ID INT, Name VARCHAR(50));

Get the information of Temp Table:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
SELECT * FROM INFORMATION_SCHEMA.INNODB_TEMP_TABLE_INFO
 
*************************** 1. row ***************************
TABLE_ID: 93
NAME: #sqlcec_9_bec
N_COLS: 5
SPACE: 76
PER_TABLE_TABLESPACE: FALSE
IS_COMPRESSED: FALSE
*************************** 2. row ***************************
TABLE_ID: 92
NAME: #sqlcec_9_beb
N_COLS: 5
SPACE: 76
PER_TABLE_TABLESPACE: FALSE
IS_COMPRESSED: FALSE
2 rows in set (0.01 sec)

Oct 18, 2016Anvesh Patel
MySQL: Script to find Largest Databases size on ServerMySQL: SELECT with Index Hint option to Optimize the Query
Comments: 3
  1. Anku
    November 23, 2016 at 7:28 am

    why its resulting N_COLS 5, can u pls elaborate? and how can be more clear about table names?

    • Anvesh Patel
      Anvesh Patel
      November 23, 2016 at 4:33 pm

      The TABLE_ID is a unique identifier for the temporary table. The NAME column displays the system-generated name for the temporary table, which is prefixed with “#sql”. The number of columns (N_COLS) is 5 rather than 1 because InnoDB always creates three hidden table columns (DB_ROW_ID, DB_TRX_ID, and DB_ROLL_PTR).

  2. castle
    January 17, 2019 at 9:05 am

    So, mighty Anvesh , how can I the get column list of temporary table in innodb engine

    I mean . how can I do the same thing when the table is a temporary one :

    SELECT GROUP_CONCAT(COLUMN_NAME SEPARATOR “,”) into r_table_cols
    FROM information_schema.COLUMNS
    WHERE TABLE_NAME = p_table_name;

    thanks a lot .

Anvesh Patel
Anvesh Patel

Database Engineer

October 18, 2016 MySQLAnvesh Patel, database, database research and development, dbrnd, find active temp table, INNODB_TEMP_TABLE_INFO, MySQL, MySQL 5.7, MySQL Command, MySQL Database Administrator, MySQL Database Designing, MySQL Database Programming, MySQL Error, MySQL Performance Tunning, MySQL Query, MySQL Tips and Tricks, Temp Table, temporary table
About Me!

I'm Anvesh Patel, a Database Engineer certified by Oracle and IBM. I'm working as a Database Architect, Database Optimizer, Database Administrator, Database Developer. Providing the best articles and solutions for different problems in the best manner through my blogs is my passion. I have more than six years of experience with various RDBMS products like MSSQL Server, PostgreSQL, MySQL, Greenplum and currently learning and doing research on BIGData and NoSQL technology. -- Hyderabad, India.

About DBRND !

dbrnd

This is a personal blog (www.dbrnd.com).

Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated.

Feel free to challenge me, disagree with me, or tell me I’m completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or anonymous comments) - so keep it polite.

The content of this website is protected by copyright. No portion of this website may be copied or replicated in any form without the written consent of the website owner.

Recent Comments !
  • Anvesh Patel { Sure will do... } – May 27, 12:43 PM
  • Anvesh Patel { Great... } – May 27, 12:41 PM
  • Anvesh Patel { Great... } – May 27, 12:39 PM
  • Anvesh Patel { Great... } – May 27, 12:36 PM
  • Anvesh Patel { Great... } – May 27, 12:28 PM
  • Anvesh Patel { Great... } – May 27, 12:27 PM
  • Anvesh Patel { Great... } – May 27, 12:16 PM
  • Older »
Follow Me !
  • facebook
  • linkedin
  • twitter
  • youtube
  • google
  • flickr
© 2015 – 2019 All rights reserved. Database Research & Development (dbrnd.com)
Posting....