Background
Break News
How to add local font to Tailwind Css and NextJS? - Tutorial Design Pattern? - Blockchain Technology, How to create own Bitcoin virtual currency - Zustand mordern management state - Design Pattern - Flyweight Pattern? - Docker Full training Topic

[Database InnoDB Engine] Some knowledge useful when working with MySQL Database - InnoDB Engine

Friday, 29 April 2022
|
Read: Completed in minutes

[Database InnoDB Engine] Some knowledge useful when working with MySQL Database - InnoDB Engine

👋👋 Hello everybody, Today I will share with you some basic knowledge you should know when working with MySQL database 😁

Do you know what default Engine in your MySQL and what is Engine on below code, and do you know what is limit size on table, on record and why use varchar 191, varchar 255 in MySQL?

Don't worry, your answer can find it on this topic


Tiktok 







Some knowledge should know when working with MySQL Database.

Your default Storage Engines is InnoDB, You can check it on phpmyadmin panel 
The one is highlight default is for Storage Engine

Some Storage Engine: 
- InnoDB - Supports transactions, row-level locking, and foreign keys
- MRG_MYISAM: Collection of identical MyISAM tables
- MEMORY: Hash based, stored in memory, useful for temporary tables
- BLACKHOLE: /dev/null storage engine (anything you write to it disappears)
- MyISAM: MyISAM storage engine
- CSV: CSV storage engine
- Archive: Archive storage engine
- PERFORMANCE_SCHEMA: Performnce Schema

 
 Default Storage Engines MySQL - InnoDB


Because we will working with default INNODB Storage Engine. So I will share with you some noted of this Engine:

We have some limit thing in Engine INNODB

Limit Table : 1017 columns, 64 secondary indexes

* A table can contain a maximum of 1017 columns (raised in MySQL 5.6.9 from the earlier limit of 1000). Virtual generated columns are included in this limit. 


* A table can contain a maximum of 64 secondary indexes. 


 

Max Key length = 3500 bytes

The InnoDB internal maximum key length is 3500 bytes, but MySQL itself restricts this to 3072 bytes. 


 

Limit Varchar size 191 vs 255

When using character-set = utf8mb3 => Limit varchar with Engine = InnoDB is 191 (767 / 4) 

When using character-set = utf8 => Limit varchar with Engine = InnoDB is 255 (767 / 3)

* If innodb_large_prefix is enabled (the default), the index key prefix limit is 3072 bytes for InnoDB tables that use the DYNAMIC or COMPRESSED row format. If innodb_large_prefix is disabled, the index key prefix limit is 767 bytes for tables of any row format. 


innodb_large_prefix is deprecated and will be removed in a future release. innodb_large_prefix was introduced in MySQL 5.5 to disable large index key prefixes for compatibility with earlier versions of InnoDB that do not support large index key prefixes. 

Index key prefixes can be up to 767 bytes. 


The index key prefix length limit is 767 bytes for InnoDB tables that use the REDUNDANT or COMPACT row format. For example, you might hit this limit with a column prefix index of more than 255 characters on a TEXT or VARCHAR column, assuming a utf8mb3 character set and the maximum of 3 bytes for each character. 
Attempting to use an index key prefix length that exceeds the limit returns an error.

Limit record per tables: around 5 billion records with 1 fields 4 bytes

On a Win32 system running NTFS, the maximum table size in MySQL is around 2TB. Assuming you have a rudimentary table with a single field of width 4 bytes, this would mean the maximum number of records a table could have is:

2.000.000.000.000 bytes / 4 bytes per field = 500.000.000.000 = 5 billion records

Limit size log in DB: less than 4GB

The combined size of the InnoDB log files must be less than 4GB.
The minimum tablespace size is 10MB. The maximum tablespace size is four billion database pages (64TB). This is also the maximum size for a table.  

Maximum LONGBLOB, LONGTEXT must be less than 4GB

The maximum row length, except for variable-length columns (VARBINARY, VARCHAR, BLOB and TEXT), is slightly less than half of a database page. That is, the maximum row length is about 8000 bytes. LONGBLOB and LONGTEXT columns must be less than 4GB, and the total row length, including BLOB and TEXT columns, must be less than 4GB. 

To avoid such errors in replication configurations, avoid enabling innodb_large_prefix on the source if it cannot also be enabled on replicas. 
If you reduce the InnoDB page size to 8KB or 4KB by specifying the innodb_page_size option when creating the MySQL instance, the maximum length of the index key is lowered proportionally, based on the limit of 3072 bytes for a 16KB page size. 

That is, the maximum index key length is 1536 bytes when the page size is 8KB, and 768 bytes when the page size is 4KB. 
The limits that apply to index key prefixes also apply to full-column index keys. 


Although InnoDB supports row sizes larger than 65.535 internally, you cannot define a row containing 

VARBINARY or VARCHAR columns with a combined size larger than 65.535:
mysql> CREATE TABLE t (a VARCHAR(8000), b VARCHAR(10000),
    -> c VARCHAR(10000), d VARCHAR(10000), e VARCHAR(10000),
    -> f VARCHAR(10000), g VARCHAR(10000)) ENGINE=InnoDB;
ERROR 1118 (42000): Row size too large. The maximum row size for the
used table type, not counting BLOBs, is 65535. You have to change some
columns to TEXT or BLOBs

After read some database secret thing. Is it useful for you? So if any question and feedback for topic "Some knowledge useful when working with MySQL Database", leave your message we can discuss about it!!

Learn Tech Tips - Zidane

references: http://download.nust.na/pub6/mysql/doc/refman/5.1/en/innodb-restrictions.html

 



🙇🏼🙇🏼 We Appreciate Your Comments and Suggestions - Webzone, all things Tech Tips web development
Popular Webzone Tech Tips topic maybe you will be like it - by Webzone Tech Tips - Zidane
As a student, I found Blogspot very useful when I joined in 2014. I have been a developer for years . To give back and share what I learned, I started Webzone, a blog with tech tips. You can also search for tech tips zidane on Google and find my helpful posts. Love you all,

I am glad you visited my blog. I hope you find it useful for learning tech tips and webzone tricks. If you have any technical issues, feel free to browse my posts and see if they can help you solve them. You can also leave a comment or contact me if you need more assistance. Here is my blog address: https://learn-tech-tips.blogspot.com.

My blog where I share my passion for web development, webzone design, and tech tips. You will find tutorials on how to build websites from scratch, using hot trends frameworks like nestjs, nextjs, cakephp, devops, docker, and more. You will also learn how to fix common bugs on development, like a mini stackoverflow. Plus, you will discover how to easily learn programming languages such as PHP (CAKEPHP, LARAVEL), C#, C++, Web(HTML, CSS, javascript), and other useful things like Office (Excel, Photoshop). I hope you enjoy my blog and find it helpful for your projects. :)

Thanks and Best Regards!
Follow me on Tiktok @learntechtips and send me a direct message. I will be happy to chat with you.
Webzone - Zidane (huuvi168@gmail.com)
I'm developer, I like code, I like to learn new technology and want to be friend with people for learn each other
I'm a developer who loves coding, learning new technologies, and making friends with people who share the same passion. I have been a full stack developer since 2015, with more than years of experience in web development.
Copyright @2022(November) Version 1.0.0 - By Webzone, all things Tech Tips for Web Development Zidane
https://learn-tech-tips.blogspot.com