search
HomeDatabaseMysql TutorialWhat is a large table in mysql? What is a big deal? How to deal with it?
What is a large table in mysql? What is a big deal? How to deal with it?Sep 17, 2018 pm 05:35 PM
mysqlmysql optimizationaffairstransaction processingperformance

The content of this article is about what is a big table in mysql? What is a big deal? How to deal with it? It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Preface

Relatively speaking, under what circumstances can a database table be called a "large table"?

  • When the data in a table exceeds tens of millions of rows, it will have an impact on the database

  • When the table data file is huge, the table data The file exceeds 10G (the data value is relative to the hardware)

The impact of large tables

The impact of large tables on queries

Slow query: It is difficult to filter within a certain period of time Obtain the required data
(Eg: display orders, few sources, low differentiation, large amount of disk IO, reduced disk efficiency, slow query)

The impact of large tables on DDL operations

1. It takes a lot of time to create an index Long-term

Risk:

MYSQL version MYSQL version>= 5.5 Although the table will not be locked, it will cause master-slave delay

2. Modifying the table structure requires locking the table for a long time

Risk:

Will cause long master-slave delay
Affects normal data operations

How to deal with it Large tables in the database

1. Split database and table. Divide a large table into multiple small tables

Difficulty:

Selection of primary keys for split tables
Query of cross-partition data after splitting tables And statistics

2. Historical data archiving of large tables

Advantages:

Reduce the impact on front-end and back-end business

Difficulties:

Archiving time Point selection
How to perform archiving operations

What is a transaction?

  • Transactions are one of the important features that distinguish the database system from all other file systems

  • A transaction is a set of atomic SQL statements. Or an independent unit of work

Transaction requirements comply with: atomicity, consistency, isolation, durability

Atomicity of transactions

A transaction must be considered The smallest unit of work that cannot be separated. All operations in the entire transaction are either submitted successfully or all fail. For a transaction, it is impossible to perform only part of the operations.

Eg:
1. Check whether the balance in the financial management account is higher than 2,000 yuan
2. Subtract 2,000 yuan from the balance of the financial management account
3. Add to the active deposit account 2000 yuan

All operations in the entire transaction are either submitted successfully, or all operations fail and are rolled back.

Transaction consistency

Consistency means that a transaction converts the database from one consistency state to another consistency state. The integrity of the data in the database is not destroyed before the transaction starts and after the transaction ends.

Isolation of transactions

Isolation requires that the modification of data in the database by a transaction is not visible to other transactions before the submission is completed.

Four types of levels defined in the SQL standard (isolation from low to high) (concurrency from high to low)

READ UNCOMMITED
Committed Read (READ COMMITED)
Repeatable Read (REPEATABLE READ)
Serializable (SERIALIZABLE)

Transaction Persistence

Once a transaction is committed, its modifications will be saved forever In the database, even if the system crashes at this time, the modified data that has been submitted will not be lost.

What is a big deal?

Transactions that take a long time to run and operate a lot of data

Risk:

Lock too much data, causing a lot of blocking and lock timeouts
Return Rolling takes a long time
The execution time is long and it is easy to cause master-slave delay

How to handle large transactions?

  • Avoid processing too much data at once

  • Move out unnecessary SELECT operations in the transaction

The above is the detailed content of What is a large table in mysql? What is a big deal? How to deal with it?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
如何在FastAPI中实现数据库连接和事务处理如何在FastAPI中实现数据库连接和事务处理Jul 30, 2023 am 11:45 AM

如何在FastAPI中实现数据库连接和事务处理引言:随着Web应用程序的快速发展,数据库连接和事务处理成为了一个非常重要的主题。FastAPI是一个高性能的PythonWeb框架,因其快速和易于使用而受到开发者的喜爱。在本文中,我们将介绍如何在FastAPI中实现数据库连接和事务处理,以帮助您构建可靠和高效的Web应用程序。第一部分:数据库连接在FastA

MySQL和Oracle:事务处理能力的比较MySQL和Oracle:事务处理能力的比较Jul 12, 2023 am 09:42 AM

MySQL和Oracle:事务处理能力的比较在数据库管理系统中,事务处理是一个关键的概念。事务是指一组数据库操作,这些操作要么全部完成,要么全部失败。因此,事务处理的能力对于数据库的稳定性和数据完整性非常重要。本文将比较MySQL和Oracle这两个主流的关系型数据库管理系统在事务处理能力方面的特点,并通过代码示例来说明。MySQL是一个开源的关系型数据库管

深入剖析MongoDB的事务处理与并发控制机制深入剖析MongoDB的事务处理与并发控制机制Nov 04, 2023 pm 03:00 PM

深入剖析MongoDB的事务处理与并发控制机制摘要:MongoDB是一种流行的NoSQL数据库,它以其高性能和可扩展性而闻名。然而,MongoDB最初并不支持事务处理和并发控制,这在某些情况下可能引发数据一致性和完整性的问题。为了解决这些问题,MongoDB在其最新版本中引入了多文档事务处理和混合隔离级别,为开发人员提供了更好的并发控制机制。引言:事务处理和

如何通过MySQL对AVG函数优化来提高性能如何通过MySQL对AVG函数优化来提高性能May 11, 2023 am 08:00 AM

如何通过MySQL对AVG函数优化来提高性能MySQL是一款流行的关系型数据库管理系统,其中包含了许多强大的函数以及功能。其中AVG函数被广泛使用在计算平均值的情形,但是由于这个函数需要遍历整个数据集,所以在大规模数据的情况下会导致性能问题。本文将详细介绍如何通过MySQL对AVG函数进行优化,从而提高性能。1.使用索引索引是MySQL优化中最重要的一部分,

如何通过PHP进行Oracle数据库的事务处理如何通过PHP进行Oracle数据库的事务处理Jul 12, 2023 am 09:31 AM

如何通过PHP进行Oracle数据库的事务处理引言:在开发Web应用程序时,数据库操作常常需要将多个操作组合在一起,以确保数据的完整性和一致性。为了满足这种需求,Oracle数据库提供了事务处理机制。本文将介绍如何使用PHP在Oracle数据库中进行事务处理,并提供相应的代码示例。连接到Oracle数据库首先,我们需要使用PHP的OCI扩展来连接到Oracl

PHP数据库事务处理的最佳实践PHP数据库事务处理的最佳实践Sep 10, 2023 pm 05:22 PM

PHP数据库事务处理的最佳实践引言:在开发Web应用程序时,数据库事务处理是一种非常重要的技术。通过使用事务,我们可以确保数据库操作的一致性和可靠性。PHP作为一种流行的Web开发语言,提供了许多方法来处理数据库事务。本文将介绍一些PHP中数据库事务处理的最佳实践。一、什么是数据库事务?数据库事务是一个要么全部成功执行,要么全部失败回滚的操作集合。在事务中,

Redis在电商系统中的作用及应用场景Redis在电商系统中的作用及应用场景Nov 08, 2023 pm 05:10 PM

Redis在电商系统中的作用及应用场景,需要具体代码示例随着电商行业的不断发展,大量数据的存储与处理已经成为了电商系统中比较重要的一环。这时候Redis这个高性能缓存数据库就显得尤为重要。在电商系统中,Redis通过其优秀的性能和灵活性,有着非常广泛的应用场景。Redis的作用高速缓存能够快速读取数据是Redis最突出的优点之一。Redis能够高速地缓存数据

基于TokuDB引擎的MySQL优化:提升写入和压缩性能基于TokuDB引擎的MySQL优化:提升写入和压缩性能Jul 25, 2023 pm 11:45 PM

基于TokuDB引擎的MySQL优化:提升写入和压缩性能引言:MySQL作为一种常用的关系型数据库管理系统,在大数据时代的背景下,面临着越来越高的写入压力和存储需求。为了应对这一挑战,TokuDB引擎应运而生。本文将介绍如何利用TokuDB引擎来提升MySQL的写入性能和压缩性能。一、什么是TokuDB引擎?TokuDB引擎是一种面向大数据的、用于处理高写入

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.