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 2017 April MySQL: InnoDB Table Compression, How we can Compressed Table?

MySQL: InnoDB Table Compression, How we can Compressed Table?

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

MySQL InnoDB Engine Table Compression, which reduces the size of database size, reduces the CPU I/O and improve overall throughput time.

The compressed data requires the small size of pages, compare to uncompressed data.
MySQL implements compression with the help of the well-known zlib library, which implements the LZ77 compression algorithm.

This compression algorithm is mature, robust, and efficient in both CPU utilization and in a reduction of data size.

Because of compressed data, processors and cache memories increases the speed of execution.
Internally buffer pool fetches the compressed data, uncompressed that data, perform the operation and again write compressed data into Disk.

The default uncompressed size of InnoDB data pages is 16KB.

If innodb_file_per_table variable enable, only we can create compressed table.

For InnoDB system tablespace, we cannot create compressed table because the single InnoDB ibdata1 file also contains other metadata information which we cannot compress.

You can access below articles for more details on InnoDB data files.

MySQL: Why InnoDB Engine stores all databases in one file (ibdata1)?

MySQL: The Truth about InnoDB File Per Table Tablespaces

Mostly, we should enable compression for a read-intensive type of application where RAM frequently uses data.
The default uncompressed size of InnoDB data pages is 16KB and Depending on the combination of option values, MySQL uses a page size of 1KB, 2KB, 4KB, 8KB, or 16KB for the tablespace data file (.ibd file).

How to create an InnoDB Compressed Table?
First In my.cnf or my.ini, innodb_file_per_table required to enable and innodb_file_format must be set to Barracuda.

1
2
SET GLOBAL innodb_file_per_table=1;
SET GLOBAL innodb_file_format=Barracuda;

We can create a table with an ROW_FORMAT=COMPRESSED option, which set compressed value half of the innodb_page_size variable.
Explicitly, we can also set a KEY_BLOCK_SIZE value to give a hint.
Here, You can check the size of innodb_page_size. (default 16KB)

1
SHOW VARIABLES LIKE 'innodb_page_size';

Create Sample InnoDB Compress Table (Set to 8KB):

1
2
3
4
5
6
7
CREATE TABLE tbl_CompressedTable
(
CID INT PRIMARY KEY
,CName VARCHAR(50)
)
ROW_FORMAT=COMPRESSED
KEY_BLOCK_SIZE=8;

Apr 1, 2017Anvesh Patel
SQL Server: Find Log Sequence Number (LSN) from Database Backup FilesMySQL: Simplest way to move your InnoDB table from one Database to another Database

Leave a Reply Cancel reply

CAPTCHA
Refresh

*

Anvesh Patel
Anvesh Patel

Database Engineer

April 1, 2017 MySQLAnvesh Patel, Barracuda, compression, database, database research and development, dbrnd, InnoDB Compressed Table, innodb_file_per_table, MySQL, MySQL Command, MySQL Database Administrator, MySQL Database Designing, MySQL Database Programming, MySQL Error, MySQL Performance Tunning, MySQL Query, MySQL Tips and Tricks, reduce size, zlib
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....