MySQL auto_increment实现

【MySQL中auto_increment有什么作用?】| 前端面试:实现一个简单的节流函数(Throttle)和防抖函数(Debounce)。 目录问题来源解释注意事项 问题来源 很多时候,MySQL语句中会出现【auto_increment】这个词汇,大多数时候,表都是自动生成的,刚开始学习MySQL数据库时会学习到,后来,渐渐地可能会忘记,那么这个语句的作用到底是什么意思?下面,来汇总一下: 解释 auto_increment是用于主键自动增长的,从1开始增长,当你把第一条记录删除时,再插入第二跳数据时,主键值是2,不是1。 例如: create table test ( id int(10) not null auto_increment, 阅读详情

运维的时候,经常遇到auto_increment的疑惑:

  1. 机器异常crash,重启后id回退的问题
  2. 性能考虑,每次获取肯定不会持久化,内存中取值,statement复制如何保证主备一致
  3. id的取值受binlog的保护吗

1. auto_increment相关的参数控制

1.1 innodb_autoinc_lock_mode

0: 每一个statement获取一个排他lock,直到statement结束,保证statement执行过程的id是连续的。
1: 单条确定insert影响的条数的时候,使用mutex。如果是insert select,load data这样的,使用排他lock。
2: 多条statement产生的id会穿插在一起,如果是statement复制,会产生不一致的情况。

1.2 
  auto_increment_increment
  auto_increment_offset
  控制自增的起始值和interval

 

2. auto_increment相关的数据结构

  1. 锁模式中LOCK_AUTO_INC,即auto_increment的表锁。

复制代码
复制代码
/* Basic lock modes */
enum lock_mode {
    LOCK_IS = 0,    /* intention shared */
    LOCK_IX,    /* intention exclusive */
    LOCK_S,        /* shared */
    LOCK_X,        /* exclusive */
    LOCK_AUTO_INC,    /* locks the auto-inc counter of a table in an exclusive mode */
    LOCK_NONE,    /* this is used elsewhere to note consistent read */
    LOCK_NUM = LOCK_NONE/* number of lock modes */
};
复制代码
复制代码

2. dict_table_t: innodb表定义

lock_t*        autoinc_lock;        表锁
mutex_t        autoinc_mutex;         mutex锁
ib_uint64_t    autoinc;            自增值
ulong        n_waiting_or_granted_auto_inc_locks;  等待自增表锁的队列数
const trx_t*        autoinc_trx;        hold自增表锁的事务

3. trx_t: 事务结构

    ulint        n_autoinc_rows;        statement插入的行数
    ib_vector_t*    autoinc_locks;  持有的自增lock

4. handler:table的innodb引擎句柄

  ulonglong next_insert_id;   下次插入的id
  ulonglong insert_id_for_cur_row; 当前插入的id
  Discrete_interval auto_inc_interval_for_cur_row; 缓存,一次申请一个区间,缓存在server层。减少对innodb的调用
  uint auto_inc_intervals_count;  向innodb申请id的interval。按照[1, 2, 4, 8, 16]递增。 最多1<<16 -1

   注意:handler里的这些变量,只在一个语句下有效,语句结束就清理掉了。

 

3. 测试case

create table pp( id int primary key auto_increment, name varchar(100));

  session1 : insert into pp(name) values('xx');
  session2 : insert into pp(name) values('xx'),('xx'),('xx'),('xx')
  session3 : insert into pp(name) select name from pp;

 

4. auto_increment的实现原理

  

 

4.2 锁的解释

根据锁持有的时间粒度,分为
  1. 内存级别:类似mutex,很快释放
  2. 语句级别:statement结束,释放
  3. 事务级别:transaction提交或者回滚才释放
  4. 会话级别:session级别,连接断开才释放

这里,session1和session2都是确定insert的条数,所以使用mutex分配固定的id。而session3未知,所以为了保证这一个statement的id是连续的,拿到一个lock,维持到statement结束才释放。

 

所以,为了提高并发量,锁持有的粒度越小越好。

4.3 缓存的解释

  针对一个statement,预分配id值,减少对innodb的请求,也相应减少持有锁。

 

5. 测试细节

5.1 第一次执行

  根据select max(id) from pp:获取autoinc的初始值
  这样也就解释了文章开头的第一个疑惑,为什么机器crash了,id会回退。

 

简单函数栈:

  ha_innobase::open
    innobase_initialize_autoinc


5.2 session 1

  1. 首先 持有mutex,获取autoinc
  2. 因为insert的条数是1条,计算新的autoinc并更新到dict_table_t中,然后释放mutex结束

  简单函数栈
  handler::update_auto_increment
    ha_innobase::get_auto_increment
      ha_innobase::innobase_lock_autoinc
        mutex_enter(&table->autoinc_mutex);
          dict_table_autoinc_update_if_greater

5.3 session 2

  1. 因为insert的条数是4条,所以前面的步骤都类似于session1,但计算完成新的autoinc为5,并更新dict_table_t.
  2. 因为cache了[3,4,5],所以后面的三条insert,都在本地缓存中获取,不再请求innodb。


5.4 session 3

  1. 因为不确定insert的条数,所以在语句的整个执行期间,持有lock。
  2. 语句结束时,statement commit的时候释放
  3. 第一次申请1个,第二次申请2个,第三次申请4个,共申请了3次。

  简单函数栈:
    handler::update_auto_increment
      ha_innobase::get_auto_increment
        row_lock_table_autoinc_for_mysql

    trans_commit_stmt
        row_unlock_table_autoinc_for_mysql

 

语句结束后, 清理语句级的环境
  ha_release_auto_increment

insert_id_for_cur_row= 0; 当前语句的insert id设置为0
auto_inc_interval_for_cur_row.replace(0, 0, 0); 预分配的清空
auto_inc_intervals_count= 0; 预分配的迭代数也清0
table->in_use->auto_inc_intervals_forced.empty(); 清理链表

 

6. 警告:

  1. 如果你的表是insert+delete的模式,你会发现重启了后,id被复用了,小心,被坑过的说。
  2. 如果表上有自增键,insert select,load file,会对insert产生阻塞。

Streamlit(九) widgets-input st.text_input / st.number_input / st.date_input / st.time_input 源码路径:${python}\Lib\site-packages\streamlit\elements\text_widgets.py(number_input.py, time_widgets.py) st.text_input st.text_input(label, value="", max_chars=None, key=None,\ 阅读详情

相关推荐

从原理到调试:手把手教你用Matlab解码互补格雷码与相移码(附数据与常见错误排查)

本文详细介绍了如何使用Matlab解码互补格雷码与相移码,涵盖从原理到调试的全过程。通过实际案例和代码示例,帮助读者掌握结构光三维重建中的相位解包裹技术,并提供了常见错误排查与优化建议,提升解码效率与准确性。

weixin_29090917的博客 218

你真的懂自增主键(auto_increment)?

   自增主键是我们在设计数据库表结构时经常使用的主键生成策略,主键的生成可以完全依赖数据库,无需人为干预,在新增数据的时候,我们只需要将主键设置为null,0或者不设置该字段,数据库就会为我们自动生成一个主键值。而且,自增主键是整数型,单调递增,对创建索引也十分友好,    自增主键使用起来方便、简单,但是你真的了解它吗?或者可以尝试回答一下几个问题? 1.自增主键标识符 auto_increment 如何增长? 2.并发环境下,数据库是如何保证主键值的正确性的? 3.可以用最大主键代替count()吗?

weixin_45701550的博客 5万+

XC7Z010-1CLG400C开发板ADC引脚配置全攻略(附完整引脚列表)

本文详细解析了XC7Z010-1CLG400C开发板的ADC引脚配置方法,涵盖XADC模块基础、CLG400封装的引脚布局、硬件设计规范及Vivado工程配置实战。特别提供了完整的引脚列表和性能优化技巧,帮助开发者高效实现模拟信号采集,适用于Zynq-7000系列开发。

weixin_29188043的博客 465

特性介绍 | MySQL 自增列详解(1):自增列概念及使用

自增列,即 AUTO_INCREMENT,可用于为新的记录生成唯一标识。要求: 2.2. 插入数据 2.3. 如何查看表的 AUTO_INCREMENT 涨到了多少? 2.4. 插入数据时能否有空洞? 可以的,但要注意 。 2.5. 能否插入重复记录 既然自增列是唯一记录,那么肯定不能插入重复记录。 2.6. 怎么修改 AUTO_INCREMENT 的值? 注意:AUTO_INCREMENT 不能小于当前自增列记录的最大值。 3. 问题 3.1. 自增列是否有上限? 由上文可见,自增列会一直增加,那是否

dbkernel 的博客 5665

利用kettle进行数据库数据比对

Kettle是一款国外开源的ETL工具,纯java编写,可以在Windows、Linux、Unix上运行,数据抽取高效稳定。本人用的版本是6.1。 之前用kettle这个开源的ETL工具是用来做数据抽取的,这次测试有个需求,是做数据库数据的比对。验证源表到目标表的逻辑正确,从而利用源表自己写SQL逻辑,生成的结果和目标表去比对。这次想到了利用kettle的数据比较功能,来做这些数据校验。 ...

多米诺DU的专栏 1万+

【数字IC设计】芯片设计中的RDC

在芯片设计中,RDC是的缩写,类似于CDC(clock domain crossing),由于现在SOC芯片是有很多ECUs组成,为了使整个系统能够快速从复位中恢复, 用户希望SOC里面每个ECU模块都可以有自己独立的异步复位信号,这样可以在出问题的时候只复位有错误逻辑的模块,而使其它模块保持正常工作。

qq_40268672的博客 2182

mysql的auto_increment

auto_increment作用:用来指定一个自增的初始值; 如果不指定值默认初始值为1 建表语句 插入数据 插入第一个数据可以看到id是从2开始 自增主键不能保证连续递增 在空表执行insert into aa values(null,1,1); 插入一条数据后,再执行show create table命令 表定义中AUTO_INCREMENT=3,表示下一次插入数据时,如果要自动生成自增值,会生成id=3。 自增值保存在表结构定义里。实际上,表结构定义存放在后缀名为.frm的文件中,但

大菜菜的博客 1万+

信号的反射(振铃、台阶、回勾、尖峰毛刺)

反射是怎么形成的 假设信号传输过程中,经过两个阻抗不同的区域,如下图所示。区域1阻抗为Z1,区域2阻抗为Z2。 在分界面处,电压必须是连续的,否则,在分界面处会产生无穷大的电场,这在真实世界中是不可能的。 同样,分界面两侧的电流必须是连续的,否则分界面处会产生无穷大的磁场。 因此: 根据欧姆定律,必然有: 显然如果Z1≠Z2的情况下,上面式子不可能同时成立。如何理解这一困境? 应该从 ...

sinat_15677011的博客 1万+

MySQL 自增列解析(Auto_increment)

MySQL数据库为列提供了一种自增属性,当列被定义为自增时。Insert语句对该列即使不提供值,MySQL也会自动为该列生成递增的唯一标识,因此这个特性广泛用于主键的自动生成。

最简单的方法,解决最实际的问题。 1万+

STM32F103标准库开发:Keil5新建STM32工程

新建STM32工程 步骤一:创建工程模板文件 新建一个文件夹 template 在文件夹template里面新建五个文件 (1)CMSIS: 存放内核驱动程序和启动引导文件 (2)FWLIB:存放库函数文件 (3)Project:存放工程文件 (4)System:存放自己写的驱动程序 (5)User:存放用户程序(主函数) 步骤二:导入stm...

MQ0522的博客 2万+

javafx结合Scene Builder自定义fxml实现漂亮的登录界面、自定义最小化、关闭按钮

本节主要介绍了如何结合Scene Builder工具来制作一个好看又漂亮的登录界面,以及介绍了如何在程序中调用生成界面文件fxml文件,如何获取到fxml文件中的组件等,并演示登录、最小化和关闭等功能。

c1007857613的专栏 5220

mysql auto_increment 原理_MySQL auto_increment实现

http://www.cnblogs.com/xpchild/p/3825309.html运维的时候,经常遇到auto_increment的疑惑:机器异常crash,重启后id回退的问题性能考虑,每次获取肯定不会持久化,内存中取值,statement复制如何保证主备一致id的取值受binlog的保护吗1. auto_increment相关的参数控制1.1 innodb_autoinc_lock_m...

weixin_35924734的博客 183

GEE生物量碳储量——利用sens和MK检验方法计算1987-2022年森林地上生物量AGB和碳储量的时空变化特征

本文是将之前已经处理好的森林生物量和碳储量数据保存到GEE Assets中,然后分别将单张影像导入到代码编辑器中,构建一个时间序列集合,并且这里需要用到的是我们给影像添加指定的时间属性,这样方便进行下一步的时序分析和空间预测。首先,需要收集1987年至2022年期间森林地上生物量AGB和碳储量数据。该数据可以通过森林清查数据、卫星遥感数据等途径获取。然后,根据这些数据,可以使用sens(敏感性分析)和MK(Mann-Kendall)方法计算时空变化特征。

此星光明博客 1264

mysql auto_inc_MySQL auto_increment实现

运维的时候,经常遇到auto_increment的疑惑:机器异常crash,重启后id回退的问题性能考虑,每次获取肯定不会持久化,内存中取值,statement复制如何保证主备一致id的取值受binlog的保护吗1. auto_increment相关的参数控制1.1 innodb_autoinc_lock_mode0: 每一个statement获取一个排他lock,直到statement结束,保证...

weixin_32173041的博客 340

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

insert时实现某一字段自增_MySQL auto_increment实现

运维的时候,经常遇到auto_increment的疑惑:机器异常crash,重启后id回退的问题性能考虑,每次获取肯定不会持久化,内存中取值,statement复制如何保证主备一致id的取值受binlog的保护吗1. auto_increment相关的参数控制1.1 innodb_autoinc_lock_mode每一个statement获取一个排他lock,直到statement结束,...

weixin_32098191的博客 1497

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

【原创】 PostgreSQL 实现MySQL 的auto_increment 字段

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_33805992的博客 681

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

MySQL事务 - 自增ID的回滚以及Auto Increment在InnoDB的实现

CREATE TABLE auto_inc_test( id int auto_increment, test_id int, primary key id(id))ENGINE=InnoDB; mysql&amp;amp;gt; start transaction; mysql&amp;amp;gt; INSERT INTO auto_inc_test (test_id) values (1); mysql&amp;amp;gt; INSE...

B-Duck-No1 3386

mysql increment by 2_【原创】 PostgreSQL 实现MySQL 的auto_increment 字段

MySQL 里面有auto_increment 自增字段,PostgreSQL 没有自增字段这一说法,但是有单独的对象:序列。 我们可以用序列或者其他土方法来是实现这样的语法。1. 用序列来实现先来创建一个步长为2的序列,最大值为10000,每次产生100个值。t_girl=# create sequence ytt.ytt_s1 start with 1 increment by 2 maxv...

weixin_32553219的博客 168

PostgreSQL 实现MySQL 的auto_increment 字段

PostgreSQL 实现MySQL的auto_increment.

四爷 4486

postgres序列mysql_PostgreSQL实现MySQL的auto_increment字段

MySQL 里面有auto_increment 自增字段,PostgreSQL 没有自增字段这一说法,但是有单独的对象:序列。 我们可以用序列或者其他土方法来是实现这样的语法。1. 用序列来实现先来创建一个步长为2的序列,最大值为10000,每次产生100个值。t_girl=# create sequence ytt.ytt_s1 start with 1 increment by 2 maxv...

weixin_39640904的博客 317

color auto mysql_MySQLauto_increment实现

运维的时候,经常遇到auto_increment的疑惑:机器异常crash,重启后id回退的问题性能考虑,每次获取肯定不会持久化,内存中取值,statement复制如何保证主备一致id的取值受binlog的保护吗1. auto_increment相关的参数控制1.1 innodb_autoinc_lock_mode0: 每一个statement获取一个排他lock,直到statement结束,保证...

weixin_30805181的博客 208
上一篇: MySQL 命令行工具之 mysqldump 深入研究
下一篇: MySQL/InnoDB处理AUTO_INCREMENT(一)
笑天居士
博客等级 码龄24年 292粉丝 136原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值