我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

多线程数据库插入,具有递增的本地ID

Given a batch of 100 books, and 100 threads, with 1 book per thread and 1 transaction per book (that could potentially rollback):

How can you safely insert those books into a MySQL table with a guarantee that each book is given an auto incrementing "local id" (i.e, "1001, 1002, ..." without gaps (remember they can potentially rollback).

Example Schema for books

id | account_id | book_title | book_author | local_id
6     12          Asdf         Jkl;           1000
82    12          John         Jane           1001

近期文章

  • 您可以使用RBAC为每个组设置个人权限吗?
  • 基于特定的子目录using.htaccess重写url
  • PHP-在查询中使用别名时的未定义索引
  • 如何在单个视图中将Joomla中的SEF URL更改为非SEF URL?
  • Codeigniter - 使用变量时无法更新数据库
  • jQuery在Wordpress中自动填充
  • Paypal IPN PHP脚本无法插入数据库
  • 如何在php中反序列化嵌套的json数组?
  • 将单独的Laravel应用程序自动加载到Lumen中
  • 控制器动作,用于改变yii2中的状态
  • json_decode无法正常工作,也没有回音
  • 如何使用AJAX从PHP传递数组
  • 使用ftp_connect连接但无法登录PHP
  • 解析XML并忽略特殊字符w / php
  • 如何使用gmail使用sendmail php windows 8.1
  • 创建变量变量的函数不起作用
  • 检查特定键的多维数组中的值
  • 为什么curlExec()的访问权限少于浏览器?
  • 在php多维中格式化单个结果以匹配?
  • symfony2一对一反转始终返回相同的结果

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华