MySQL分区技术(一)_MySQL
4:MySQL 分区技术(是mysql 5.1以版本后开始用->是甲骨文mysql技术团队维护人员以插件形式插入到mysql里面的技术)
目前,针对海量数据的优化主要有2中方法:
1:大表拆成小表的方式(物理上)
一:垂直分表->一张垂直切成几张
二:水平分表(一般重点)->横切,意思就是一张表有100个数据横切10张表,一张表存10条(字段一致)
2:SQL语句的优化(可以通过增加索引等来调整,但是数据量大的增大会导致索引的维护代价增大)
水平分区技术将一个表拆成多个表,比较常用的方式是将表中的记录按照某种hash算法进行拆分,简单的拆分方法如取摸
方式。同样,这种分区方法也必须对前端的应用程序中的SQL进行修改方可以使用。而且对于一个SQL,它可能会修改两个
表,那么你必须地写出2个SQL语句从而可以完成一个逻辑事务,使得程序的判断逻辑越来越复杂,这样也导致程序的维护代价
高,也就失去了采用数据库的优势。
*因此:分区技术可以有力地避免如上的弊端,成为解决海量数据存储的有力方法。
分区技术:
->>有效解决了:物理上拆分多个表,逻辑上操作一个表表明不变
->>MySQL分区技术介绍(*主要用的是range 和 list 分区*):
-----分区在逻辑上是一张表,在硬件/物理上是多张表,就是拆分表索引和数据-----
MySQL的分区技术不同与之前的分表技术,它与水平分表有点类似,但是它在逻辑层进行的水平分表,
对与应用程序而言它还是一张表,
MySQL5.1版本后有4中分区类型:
一:RANGE分区(用的最多):基于属于一个给定连续区间的列值(字段),把多行分配给分区 -->基于女字段为参考点来进行分区
--将一个表拆分成:索引文件,数据文件分片存储
二:LIST分区:类似于按range分区,区别在于list分区是基于列值匹配一个离散值集合中的某个值来进行选择(列里面的值是固定值时候来进行分区,而且是枚举类型的值适合用list分区 -->比如说 性别:男,女)
三:HASH分区:基于用户定义的表达式的返回值来进行选择的分区,改表达式使用将要插入到表中的这些行的列值计算,这个函数可以包含MySQL中有效的、产生负整数值的任何表达式
--->把每次插入的数据随机的平均的分配到多个分区里面,最终多个分区里面的数据时平均分配的,但是每个分区里面的数值肯能不太一样,因为是随机分配的(一般可以用来做MySQL分区的测试来使用)
四:KEY分区:类似于按hash分区,区别在于key分区只支持计算一列或多列,且MySQL服务器提供其自身的哈希函数
测试一下(测试用hash类型的):->myisam增删改查的速度快
create table t2(id int)engine=myisam
partition by hash(id)
partitions 5; ->能后当你插入数据的时候就会随机分配插入个个分区中
建立一个存储
\d // ->修改结束符号 之前是;号改成 //
create procedure p5()
begin
set @i=1;
while @i
insert into t4 values(@i);
set @i=@i+1;
end while;
end //
执行刚才建立的存储
call p3() ->表p3就插入了9999条数据
innodb的数据结构:
分为:共享表空间及其独占表空间
一:innodb表结构共享表空间不能做成分区表:
所有文件的数据和索引都在ibddata1(比如你建了2个表会对应生成frm文件,但是2个表的所有数据和索引全部在这个文件里面共用,所有不能对表做正真的分区,初始值是10M)
原因:数据和索引全都是放在一个文件里面 .ibddata1文件
二:innodb表结构要想做出分区表必须是“独占表空间”
原因:数据和索引全都是独立的一个文件
开启独占空间:(*必须配置文件中开启文件才能做出独占表空间,才能做成分区表*)
innodb_data_home_dir = C:\mysql\data\
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = C:\mysql\data\
innodb_file_per_table=1 ->配置文件中innodb下方加上
重启:MySQL -->pkill mysqld 关闭进程 重新启动MySQL-bin/mysqld_safe --user=mysql &
测试:
create table t4(id int)engine=innodb
partition by RANGE(id)(
partition p0 values less than(10000),
partition p1 values less than(20000),
PARTITION p2 VALUES less than MAXVALUE);
能后你在创建innodb类型的数据表后,你会发现建一个x表就有x.frm x.ibd文件,就不会和其他表放到一起从而做表分区
*重点总结:只有把innodb设置成独立的表空间后,才能创建innodb表引擎的表分区
相关命令:
/s; 查看详细信息版本啊编码啊 什么的。。。
show engines; 查看默认表引擎
show plugins; 查看当前MySQL的所有插件,可以查看是否支持分区partition
show index from from tabName; 查看索引
show procedure status; 查看简历的存储

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

StableDiffusion3’s paper is finally here! This model was released two weeks ago and uses the same DiT (DiffusionTransformer) architecture as Sora. It caused quite a stir once it was released. Compared with the previous version, the quality of the images generated by StableDiffusion3 has been significantly improved. It now supports multi-theme prompts, and the text writing effect has also been improved, and garbled characters no longer appear. StabilityAI pointed out that StableDiffusion3 is a series of models with parameter sizes ranging from 800M to 8B. This parameter range means that the model can be run directly on many portable devices, significantly reducing the use of AI

The first pilot and key article mainly introduces several commonly used coordinate systems in autonomous driving technology, and how to complete the correlation and conversion between them, and finally build a unified environment model. The focus here is to understand the conversion from vehicle to camera rigid body (external parameters), camera to image conversion (internal parameters), and image to pixel unit conversion. The conversion from 3D to 2D will have corresponding distortion, translation, etc. Key points: The vehicle coordinate system and the camera body coordinate system need to be rewritten: the plane coordinate system and the pixel coordinate system. Difficulty: image distortion must be considered. Both de-distortion and distortion addition are compensated on the image plane. 2. Introduction There are four vision systems in total. Coordinate system: pixel plane coordinate system (u, v), image coordinate system (x, y), camera coordinate system () and world coordinate system (). There is a relationship between each coordinate system,

Trajectory prediction plays an important role in autonomous driving. Autonomous driving trajectory prediction refers to predicting the future driving trajectory of the vehicle by analyzing various data during the vehicle's driving process. As the core module of autonomous driving, the quality of trajectory prediction is crucial to downstream planning control. The trajectory prediction task has a rich technology stack and requires familiarity with autonomous driving dynamic/static perception, high-precision maps, lane lines, neural network architecture (CNN&GNN&Transformer) skills, etc. It is very difficult to get started! Many fans hope to get started with trajectory prediction as soon as possible and avoid pitfalls. Today I will take stock of some common problems and introductory learning methods for trajectory prediction! Introductory related knowledge 1. Are the preview papers in order? A: Look at the survey first, p

This paper explores the problem of accurately detecting objects from different viewing angles (such as perspective and bird's-eye view) in autonomous driving, especially how to effectively transform features from perspective (PV) to bird's-eye view (BEV) space. Transformation is implemented via the Visual Transformation (VT) module. Existing methods are broadly divided into two strategies: 2D to 3D and 3D to 2D conversion. 2D-to-3D methods improve dense 2D features by predicting depth probabilities, but the inherent uncertainty of depth predictions, especially in distant regions, may introduce inaccuracies. While 3D to 2D methods usually use 3D queries to sample 2D features and learn the attention weights of the correspondence between 3D and 2D features through a Transformer, which increases the computational and deployment time.

Some of the author’s personal thoughts In the field of autonomous driving, with the development of BEV-based sub-tasks/end-to-end solutions, high-quality multi-view training data and corresponding simulation scene construction have become increasingly important. In response to the pain points of current tasks, "high quality" can be decoupled into three aspects: long-tail scenarios in different dimensions: such as close-range vehicles in obstacle data and precise heading angles during car cutting, as well as lane line data. Scenes such as curves with different curvatures or ramps/mergings/mergings that are difficult to capture. These often rely on large amounts of data collection and complex data mining strategies, which are costly. 3D true value - highly consistent image: Current BEV data acquisition is often affected by errors in sensor installation/calibration, high-precision maps and the reconstruction algorithm itself. this led me to

Suddenly discovered a 19-year-old paper GSLAM: A General SLAM Framework and Benchmark open source code: https://github.com/zdzhaoyong/GSLAM Go directly to the full text and feel the quality of this work ~ 1 Abstract SLAM technology has achieved many successes recently and attracted many attracted the attention of high-tech companies. However, how to effectively perform benchmarks on speed, robustness, and portability with interfaces to existing or emerging algorithms remains a problem. In this paper, a new SLAM platform called GSLAM is proposed, which not only provides evaluation capabilities but also provides researchers with a useful way to quickly develop their own SLAM systems.

Please note that this square man is frowning, thinking about the identities of the "uninvited guests" in front of him. It turned out that she was in a dangerous situation, and once she realized this, she quickly began a mental search to find a strategy to solve the problem. Ultimately, she decided to flee the scene and then seek help as quickly as possible and take immediate action. At the same time, the person on the opposite side was thinking the same thing as her... There was such a scene in "Minecraft" where all the characters were controlled by artificial intelligence. Each of them has a unique identity setting. For example, the girl mentioned before is a 17-year-old but smart and brave courier. They have the ability to remember and think, and live like humans in this small town set in Minecraft. What drives them is a brand new,

Written above & The author’s personal understanding is that image-based 3D reconstruction is a challenging task that involves inferring the 3D shape of an object or scene from a set of input images. Learning-based methods have attracted attention for their ability to directly estimate 3D shapes. This review paper focuses on state-of-the-art 3D reconstruction techniques, including generating novel, unseen views. An overview of recent developments in Gaussian splash methods is provided, including input types, model structures, output representations, and training strategies. Unresolved challenges and future directions are also discussed. Given the rapid progress in this field and the numerous opportunities to enhance 3D reconstruction methods, a thorough examination of the algorithm seems crucial. Therefore, this study provides a comprehensive overview of recent advances in Gaussian scattering. (Swipe your thumb up
