当前位置: 首页 > article >正文

ShardingSphere-Proxy分表场景测试案例

快速入门文章参考:《ShardingSphereProxy:快速入门》

基于K8S部署文章参考:《基于K8s部署ShardingSphere-Proxy》

基于golang的测试用例参考:《ShardingSphere-Proxy 连接实战:从 Golang 原生 SQL 到 GORM 的应用》

背景

我们需要具体的看一下ShardingSphere-Proxy分表组件的边界,因此,我测试了常用的41个场景。

数据库表结构

我们对订单表(orders)基于 user_id 进行了分表操作,共分为四张表。而用户表(user)和产品表(product)则未进行分表处理,它们的建表语句如下:

DROP TABLE IF EXISTS `orders`;
CREATE TABLE `orders_0`  (
  `id` bigint NOT NULL,
  `order_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `user_id` int NOT NULL,
  `product_id` int NOT NULL,
  `order_date` bigint NOT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user`  (
  `id` bigint NOT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
DROP TABLE IF EXISTS `product`;
CREATE TABLE `product`  (
  `id` bigint NOT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

测试场景

项目说明是否包含分表键测试sql结果
全表查询SELECT * FROM `orders`;支持
等值查询SELECT * FROM `orders` WHERE order_id='20240101ORDER9503';支持
SELECT * FROM `orders` WHERE user_id=8648;支持
and查询SELECT * FROM `orders` WHERE order_id='20240101ORDER6546' AND product_id=861;支持
and查询SELECT * FROM `orders` WHERE user_id=4581 AND product_id=213支持
范围查询in查询SELECT * FROM `orders` WHERE user_id IN (2608,4581,2142,3519)支持
in查询SELECT * FROM `orders` WHERE order_id IN ('20240101ORDER6546','20250101ORDER2295','20250101ORDER4465','20240101ORDER7826')支持
between查询SELECT * FROM `orders` WHERE order_id BETWEEN '20240101ORDER6546' AND '20240101ORDER6548支持
between查询SELECT * FROM `orders` WHERE user_id BETWEEN 4581 AND 4583支持
or查询SELECT * FROM `orders` WHERE order_id = '20240101ORDER6546' OR order_id = '20250101ORDER2295'支持
or查询SELECT * FROM `orders` WHERE user_id = 4581 OR user_id = 3519支持
>查询 SELECT * FROM `orders` WHERE order_id > '20240101ORDER6546'支持
>查询SELECT * FROM `orders` WHERE user_id > 4581支持
累加聚合sumSELECT SUM(product_id) FROM `orders` WHERE order_id='20240101ORDER6546'支持
sumSELECT SUM(product_id) FROM `orders` WHERE user_id=4581支持
sumSELECT SUM(product_id) FROM `orders`
countSELECT count(*) FROM `orders` WHERE order_id='20240101ORDER6546'支持
countSELECT count(*) FROM `orders` WHERE user_id=4581支持
countSELECT count(*) FROM `orders`支持
比较聚合max否        SELECT MAX(user_id) FROM `orders`支持
minSELECT MIN(user_id) FROM `orders`支持
平均聚合avgSELECT AVG(user_id) FROM `orders`支持
分组groupSELECT *,SUM(product_id) AS sum_product,MAX(product_id) as max_product FROM `orders` GROUP BY `order_id`支持
groupSELECT *,SUM(product_id) AS sum_product,MAX(product_id) as max_product FROM `orders` GROUP BY `user_id`支持
排序、分页order/limit否        SELECT * FROM `orders` ORDER BY order_id desc LIMIT 5支持
order/limitSELECT * FROM `orders` ORDER BY user_id desc LIMIT 5支持
去重DISTINCT SELECT DISTINCT `order_id` FROM `orders`支持
DISTINCTSELECT DISTINCT `user_id` FROM `orders`支持
关联查询joinSELECT orders.*,product.* FROM `orders` JOIN product ON orders.product_id = product.id支持
joinSELECT orders.*,user.* FROM `orders` JOIN user ON orders.user_id = user.id支持
子查询SELECT subquery.* FROM (SELECT orders.* FROM orders JOIN product ON orders.product_id = product.id) AS subquery支持
SELECT subquery.* FROM (SELECT orders.* FROM orders JOIN user ON orders.user_id = user.id) AS subquery支持
INSELECT * FROM orders WHERE user_id IN (SELECT id FROM user)支持
UNIONUNIONSELECT * FROM orders WHERE user_id = 8648 UNION SELECT * FROM orders WHERE user_id = 3401支持
UNIONSELECT * FROM orders WHERE order_id = '20240101ORDER6546' UNION SELECT * FROM orders WHERE order_id = '20240101ORDER9728'
UNION ALLSELECT * FROM orders WHERE order_id = '20240101ORDER6546' UNION SELECT * FROM orders WHERE order_id = '20240101ORDER9728'支持
UNION ALLSELECT * FROM orders WHERE order_id = '20240101ORDER6546' UNION ALL SELECT * FROM orders WHERE order_id = '20240101ORDER9728'支持
UPDATE根据主键更新UPDATE `orders` SET `product_id`=1 WHERE id = 1866023311733952512支持
UPDATE `orders` SET `product_id`=1 WHERE user_id = 9148支持
DELETE根据主键删除DELETE FROM `orders` WHERE id = 1866023311071252480支持
DELETE FROM `orders` WHERE user_id = 4389支持
INSERTINSERT INTO `orders` (`order_id`,`user_id`,`product_id`,`order_date`,`id`) VALUES ('20240101ORDER1227',1660,106,1735632223,1874003486933258240)支持


http://www.kler.cn/a/463057.html

相关文章:

  • 网络安全 | 信息安全管理体系(ISMS)认证与实施
  • zookeeper+kafka
  • xdoj isbn号码
  • C++并发编程之内存顺序一致性
  • 实现单例模式的五种方式
  • 2024/12/29 黄冈师范学院计算机学院网络工程《路由期末复习作业一》
  • CPT203 Software Engineering 软件工程 Pt.4 软件设计(中英双语)
  • Spring 核心技术解析【纯干货版】- II:Spring 基础模块 Spring-Beans 模块精讲
  • pyside6总结
  • 网络编程原理:回显服务器与客户端通信交互功能
  • Day20:逻辑运算
  • 30.Marshal.AllocHGlobal C#例子
  • 递归算法.
  • AI对接之JSON Output
  • 使用连字符容易出错,尽量使用驼峰式的
  • java 上传txt json等类型文件解析后返回给前端
  • OpenCV-Python实战(9)——滤波降噪
  • C++“STL之String”
  • 说说缓存使用的具体场景都有哪些?缓存和数据库一致性问题该如何解决?缓存使用常见问题有哪些?
  • 融合表面信息和等变扩散的分子对接模型 SurfDock - 评测
  • Git的使用流程(详细教程)
  • NFT Insider #162:Cool Cats和Doodles或将推出代币
  • 线性表的三种常见查找算法(顺序查找、折半查找、分块查找)及算法分析
  • 无人机巡检在光伏电站中的应用优势
  • HarmonyOS NEXT版本Stage应用开发模型介绍(附视频讲解)
  • SWM221系列芯片之电机应用及控制