Getting Started with Rails & TiDB

TiDB的系统变量 TiDB 系统变量的行为与 MySQL 相似,变量的作用范围可以是会话级别有效 (Session Scope) 或全局范围有效 (Global Scope)。SESSIONGLOBALSESSIONSESSION注意部分GLOBAL作用域的变量会持久化到 TiDB 集群中。文档中的变量有一个“是否持久化到集群”的说明,可以为“是”或者“否”。tidb.toml此外,由于应用和连接器通常需要读取 MySQL 变量,为了兼容这一需求,在 TiDB 中,部分 MySQL 的变量既可读取也可设置。 阅读详情

Getting Started with Rails & TiDB

也许是第一份 Rails + TiDB集成的资料,网上新手入门方面的文章太少了,而且ActiveRecord这种复杂的ORM和TiDB集成还确实有一些门槛,所以就写了这么一个入门教程。

搭建本地TiDB开发环境

安装TiUP

TiUP 安装过程十分简洁,无论是 Darwin 还是 Linux 操作系统,执行一行命令即可安装成功:

curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh

本机启动集群

tiup playground

输出

tiup playground
Starting component `playground`: /Users/hooopo/.tiup/components/playground/v1.4.1/tiup-playground
Use the latest stable version: v5.0.0

    Specify version manually:   tiup playground <version>
    The stable version:         tiup playground v4.0.0
    The nightly version:        tiup playground nightly

Playground Bootstrapping...
Start pd instance
Start tikv instance
Start tidb instance
Waiting for tidb instances ready
127.0.0.1:4000 ... Done
Start tiflash instance
Waiting for tiflash instances ready
127.0.0.1:3930 ... Done
CLUSTER START SUCCESSFULLY, Enjoy it ^-^
To connect TiDB: mysql --host 127.0.0.1 --port 4000 -u root -p (no password)
To view the dashboard: http://127.0.0.1:2379/dashboard
To view the Prometheus: http://127.0.0.1:9090
To view the Grafana: http://127.0.0.1:3000

dashboard

详细文档

  • https://docs.pingcap.com/zh/tidb/stable/tiup-overview

Rails & TiDB 配置

创建Rails项目

rails new myapp --database=mysql

database.yml配置

default: &default
  adapter: mysql2
  encoding: utf8mb4
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  port: 4000
  username: root
  password:
  host: 127.0.0.1
  variables:
    tidb_enable_noop_functions: ON

注意,tiup启动的本地集群默认端口是4000,设置数据库connection变量tidb_enable_noop_functions: ON,因为Rails需要使用get_lock函数,tidb里默认是关闭的。

如果你使用URI的方式配置数据库链接,也是类似:

default: &default
  adapter: mysql2
  encoding: utf8mb4
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  url: <%= ENV.fetch("DB_URL") || "mysql2://root:pass@localhost:4000/myapp" %>
  variables:
    tidb_enable_noop_functions: ON

主键、自增、唯一索引

创建一个users表:

class CreateUsers < ActiveRecord::Migration[6.1]
  def change
    create_table :users do |t|
      t.string :email
      t.string :password
      t.string :username

      t.timestamps
    end
  end
end

加一个唯一索引

class AddUniqueIndexForEmail < ActiveRecord::Migration[6.1]
  def change
    add_index :users, :email, unique: true
  end
end

和使用单机MySQL没有任何区别,TiDB已经兼容的很好了,相比其他分布式数据库上手起来容易很多,一些分布式数据库主键、自增、唯一索引这些功能都是不兼容的,需要额外处理。

看看生成的数据表:

mysql> show create table users;
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                                                                                                                                                                                                                                                                                             |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| users | CREATE TABLE `users` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `email` varchar(255) DEFAULT NULL,
  `password` varchar(255) DEFAULT NULL,
  `username` varchar(255) DEFAULT NULL,
  `created_at` datetime(6) NOT NULL,
  `updated_at` datetime(6) NOT NULL,
  PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
  UNIQUE KEY `index_users_on_email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=30001 |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

savepoint patch

TiDB和ActiveRecord结合的唯一障碍就是TiDB不支持savepoint,我写了个简单的patch来解决:

# https://github.com/rails/rails/blob/6-1-stable/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb#L313
require 'active_record/connection_adapters/abstract/database_statements.rb'


module DisableSavepoint
  def transaction(requires_new: nil, isolation: nil, joinable: true)
    if requires_new
      requires_new = nil
      Rails.logger.warn "savepoint statement was used, but your db not support, ignored savepoint."
      Rails.logger.warn caller
      super(requires_new: requires_new, isolation: isolation, joinable: joinable)
    else
      super(requires_new: requires_new, isolation: isolation, joinable: joinable)
    end
  end
end

ActiveRecord::ConnectionAdapters::DatabaseStatements.send(:prepend, DisableSavepoint)

原理就是,Rails里只有在transaction传参requires_new为true的时候才会引入savepoint,通过patch把requires_new为true的地方变成nil,再输出日志来迁移。我的经验大部分Rails项目用到savepoint的地方不多,如果想迁移不是很难。跑migration的时候会引入savepoint,但在没有并发执行migration的场景直接去掉也没有什么影响。

Links

开发 Java 应用使用 TiDB 的最佳实践 本文从常用的和数据库交互的Java组件的角度,阐述了开发Java应用程序使用TiDB的常见问题与解决办法。TiDB是高度兼容MySQL协议的数据库,基于MySQL开发的Java应用的最佳实践也多适用于TiDB。欢迎大家在ASKTUG踊跃发言,和我们一起分享讨论Java应用使用TiDB的实践技巧或遇到的问题。httpshttps。... 阅读详情

相关推荐

TiDB 配置参数

符号,因为它可能引入安全风险,允许来自任何 IP 的客户端自行汇报其 IP 地址。另外,它可能会导致部分直接连接 TiDB 的内部组件无法使用,例如 TiDB Dashboard。本文将详细介绍 TiDB 的命令行启动参数。TiDB 的默认端口为 4000(客户端请求)与 10080(状态报告)。要快速了解 TiDB 的参数体系与参数作用域,建议先观看下面的培训视频(时长 17 分钟)。在启动 TiDB 时,你可以使用命令行参数或环境变量来配置 TiDB。除非特殊情况,一般使用默认值即可。

weixin_42241611的博客 2484

tidb替换mysql遇到的问题记录

SELECT list is not in GROUP BY clause and contains nonaggregated column 'mysql.user.Update_priv' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by sql_mode中去掉only_full_groupby set glo..

liusf1993的博客 2996

获取气体传感器温度调制响应数据并转换为NumPy数组

本任务旨在获取气体传感器在温度调制条件下的响应数据,将其处理为结构化数据格式(NumPy数组),以便用于机器学习模型训练。整个过程包含数据采集、预处理、特征工程和格式转换等关键步骤。

huanghm88的专栏 1207

TiDB 升级利器(参数对比)——TiDBA

作者: 啦啦啦啦啦 原文来源: https://tidb.net/blog/299f0bdc ...

TiDB 社区干货传送门 901

sap2000 api matlab,SAP2000_API入门指南.pdf

SAP2000_API入门指南北 京 金 土 木 软 件 技 术 有 限 公 司Beijing Civil King Software TechnologyCo., Ltd.SAP2000 API 入门指南余承飞 韦群跃 汤娣概述SAP2000 API 是从 SAP2000 V11 开始引进的,即应用软件编程接口。用户可以编写程序,通过API 随心所欲地调用 SAP2000...

weixin_42118423的博客 1941

LabVIEW多界面应用开发:从启动器到主界面的切换架构与实现

在图形化编程领域,模块化与界面管理是构建复杂应用程序的核心。其原理在于通过清晰的程序架构,实现不同功能模块间的独立运行与协同工作,从而提升代码的可维护性和可扩展性。这种架构的技术价值在于能够有效管理应用程序的生命周期与资源,避免内存泄漏,并确保流畅的用户体验。在测控系统、自动化测试等工程实践中,常需实现如启动界面选择语言或模式后,无缝切换至主功能界面的场景。本文聚焦于LabVIEW环境,深入探讨如何利用动态调用、状态机等机制,并结合功能全局变量(FGV)与队列消息处理器(QMH)等热词技术,构建健壮的多界面

weixin_30802819的博客 262

升级5.1.1小问题

作者:刘春雷 原文来源: https://tidb.net/blog/f88a8801 ...

TiDB 社区干货传送门 339

ConvLSTM时空预测实战代码详解

ConvLSTM代码复现

JaysonWong的博客 1万+

ActiveRecord-TiDB适配器使用指南

ActiveRecord-TiDB适配器使用指南 目录结构及介绍 在activerecord-tidb-adapter项目中,主要的目录结构及功能描述如下: 主要目录 bin: 包含脚本用于初始化环境或执行特定任务。 lib: 存储了核心代码逻辑和类定义,包括了activerecord-tidb-adapter的主要功能实现。 test: 测试文件的位置,包含单元测试和其他验证代码正确性的工具。...

gitblog_00020的博客 400

R语言使用mlr包创建回归任务、指定回归学习函数为KNN回归模型、网格搜索、交叉验证调节KNN模型的超参数K获取模型最佳的K值、可视化KNN模型的不同K值和MSE指标之间关系图

R语言使用mlr包创建回归任务、指定回归学习函数为KNN回归模型、网格搜索、交叉验证调节KNN模型的超参数K获取模型最佳的K值、可视化KNN模型的不同K值和MSE指标之间关系图

statistics+insight+vista+power 279

面试真题集(十六):TensorRT基础

TensorRT面试真题解析:从模型优化到推理部署 本文精选了14道TensorRT面试题,涵盖选择题、简答题和场景题,深度考察推理工程师对TensorRT核心技术的理解。内容聚焦三个关键维度: 基础概念 FP16推理中Softmax层为何需保持FP32(数值稳定性) INT8校准原理(EntropyCalibrator2的鲁棒性优势) Plugin V3接口的构建/运行分离设计 性能优化 Conv-BN-ReLU融合减少40-60%延迟的关键机制(访存优化) 动态Shape配置策略(min/opt/max

PeterPan的博客 69

TiDB升级与案例分享(TiDB v4.0.1 → v5.4.1)

作者: GreenGuan 原文来源: https://tidb.net/blog/d02ba4a5 ...

TiDB 社区干货传送门 1006

基于 STM32 单片机的实验室多参数安全监测系统设计与实现

本系统以 STM32F103C8T6 单片机为核心,集成温湿度监测、烟雾检测、气体泄漏报警、人体移动监测等功能模块,通过 OLED 显示屏实时显示数据,并支持 Wi-Fi 远程传输。系统可对实验室异常环境参数(如高温、烟雾、燃气泄漏)及非法入侵实时报警,保障实验室安全。本文从硬件选型、电路设计到软件实现提供了完整的实验室安全监测系统方案,可根据实际需求调整传感器类型和通信方式,适用于科研、教学等场景的环境安全防护。:可增加继电器模块控制通风设备或切断电源,集成 ZigBee 组网实现多实验室联动监测。

weixin_42300449的博客 1285

tidb使用坑记录

1、对硬盘要求很高,没上SSD硬盘的不建议使用 2、不支持分区,删除数据是个大坑。 解决方案:set @@session.tidb_batch_delete=1;  3、插入数据太大也会报错 解决方案:set @@session.tidb_batch_insert=1;  4、删除表数据时不支持别名 delete from 表名 表别名 where 表别名.col = '1'  会报错...

weixin_34194359的博客 4408

孔雀优化算法(POA)详解:从孔雀智能到优化引擎

孔雀优化算法(POA)是一种新型元启发式优化算法,灵感来源于孔雀的社会行为和智能狩猎策略。该算法将孔雀群体分为雄孔雀、雌孔雀和幼孔雀三个阶层,分别对应全局探索、平衡搜索和局部开发三种搜索策略。通过模拟孔雀的求偶展示、自适应接近和Levy飞行等行为,POA实现了探索与开发的动态平衡。算法采用角色分配机制和位置更新方程,结合参数自适应调整,展现出优于传统算法的全局搜索能力和收敛性能。POA已成功应用于多个优化问题,其生物启发机制为解决复杂优化问题提供了新思路。

qq_42212808的博客 135

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

从TiDB搭建到监控闭环

作者: xie123 原文来源: https://tidb.net/blog/341d7ea4 ...

TiDB 社区干货传送门 606

IEM模型,地表粗糙度模拟

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

TiDB 在华泰证券的探索与实践

文章转载自公众号华泰证券数字科技。 原文链接:https://mp.weixin.qq.com/s/Hp-ZJLdvd3z2w9IJ_32NRw?scene=25#wechat_redirect 作者介绍 华泰证券数字科技分布式数据库项目组,主要负责华泰证券分布式数据库系统建设工作,项目组成...

chigangdou7652的博客 383

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

深度学习工具包 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&#39;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 = &quot;R. B. Palm&quot;, title = &quot;Prediction as a candidate for learning deep hierarchical models of data&quot;, year = &quot;2012&quot;,}```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(&#39;DeepLearnToolbox&#39;));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(&#39;state&#39;,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&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,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 = &#39;sigm&#39;;%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 &lt; 0.10, &#39;Too big error&#39;);```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(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;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)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;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 &lt; 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% 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&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 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&lt;0.12, &#39;Too big error&#39;);```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(&#39;state&#39;,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 &lt; 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,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 &lt; 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,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 &lt; 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % 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 &lt; 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % 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 &lt; 0.1, &#39;Too big error&#39;);%% 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(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % 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 &lt; 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free &quot;Bitdeli Badge&quot;)

《TiDB跨版本升级》 --流程概述

作者: Coke 原文来源: https://tidb.net/blog/babd94b2 ...

TiDB 社区干货传送门 603

数据库并发操作可能出现的问题及解决方式

并发操作可能出现的问题 两类丢失更新 脏读 没提交就读到 幻读 如何处理 锁机制: 事务隔离级别 自动加锁 读未提交 – 会发生脏读 读提交 – 会发生不可重复读,不会读到脏数据 可重复读 – 重复读到之前的数据。在一个事务中。 测试不同隔离级别下并发操作出现的问题 开启事务环境 mysql&gt; begin; start transaction ; commit ; rollback; 查看 更改事务 mysql&gt; select @@tx_isolation; mysql&gt; set se

echo666的博客 7224

TiDB 最佳实践系列(五)Java 数据库应用开发指南

作者:Su Li,Zhang Ming Java 是当前非常流行的开发语言,很多 TiDB 用户的业务层都是使用 Java 开发的,本文将从 Java 数据库交互组件开发的角度出发,介绍各组件的推荐配置和推荐使用方式,希望能帮助 Java 开发者在使用 TiDB 时能更好的发挥数据库性能。 Java 应用中的数据库相关组件 通常 Java 应用中和数据库相关的常用组件有: 网络协议:客户端通过...

TiDB_PingCAP 的博客 3354

解析 TiDB 在线数据同步工具 Syncer

摘要:详细介绍了如何将 MySQL 的数据迁移到 TiDB,并将 TiDB 作为 MySQL 的 Slave 进行数据同步。(作者:崔秋) TiDB 是一个完全分布式的关系型数据库,从诞生的第一天起,我们就想让它来兼容 MySQL 语法,希望让原有的 MySQL 用户 (不管是单机的 MySQL,还是多机的 MySQL Sharding)...

weixin_33709609的博客 561

TiDB和Mysql的sql差异总结

简介 根据网上一些使用案例列出目前TiDB和mysql在使用上的区别和目前的遇到的常见问题及解决方案,当然具体的使用问题还需要大量的线下测试才能确认。   问题类型 问题描述 原因及解决办法 DDL 在一个 DDL 里不能对多个列或者多个索引做操作。 ADD/DROP INDEX/COLUMN 操作目前不支持同时创建或删除多个索引或列, 需要拆分单...

m0_37683758的博客 1万+

mysql写偏斜_(三)分布式数据库tidb-隔离级别详解

TiDB在执行selectforupdate时相当于悲观锁系统中将锁等待时间设置为0,遇到锁冲突的事务会执行失败。综上,TiDB不适合用于处理高并发的对同一行数据进行修改,事务使用了selectfor快地被响应,使得每个进程都像是被公平对待,这是非常感人的。但是时间共享却带来了另外一个问题,站在进程的角度上看,每个进程从启动开始到执行完成,中间需要花费更长时间,而且很多时间处于等待状态。再考虑另外...

weixin_42515093的博客 542

猿创征文|TiDB单机部署最佳实践

最近客户项目要求,基于Centos7的环境部署TiDB 6.3 单机环境,详细的过程分享给大家

IT邦德 2006

TiDB、mysql修改系统变量/常用语句(杀死process中的进程)

-- 查询所有全局变量 SHOW GLOBAL VARIABLES; -- 查询所有会话变量 SHOW SESSION VARIABLES; -- 指定查询全局变量 SELECT @@GLOBAL.tidb_retry_limit; -- 指定查询会话变量 SELECT @@SESSION.tidb_retry_limit; -- 优先查询会话变量,再查询全局变量 SELECT @@tidb_r...

记录点滴生活 3009

TiDB使用限制

文章目录一、标识符长度限制二、Databases、Tables、Views、Connections 总个数限制三、单个 Database 的限制四、单个 Table 的限制五、单行的限制六、单列的限制七、字符串类型限制八、SQL Statements 的限制 一、标识符长度限制 标识符类型 最大长度(字符) Database 64 Table 64 Cloumn 64 Index 64 View 64 Sequence 64 二、Databases、Tables、Vi

雪辉博客 1300
上一篇: 像 C 一样快,Ruby 般丝滑的 Crystal 发布 1.0 版本,你看好吗? | 极客分享第 24 期
采蘑菇的安琪拉
博客等级 码龄12年 0粉丝 29原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值