下载BenchmarkSQL并使用BenchmarkSQL查看OceanBase 的执行计划

2024-03-13 05:28

本文主要是介绍下载BenchmarkSQL并使用BenchmarkSQL查看OceanBase 的执行计划,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

下载BenchmarkSQL并使用BenchmarkSQL查看OceanBase 的执行计划

  • 一、什么是BenchmarkSQL
  • 二、下载BenchmarkSQL
  • 三、使用BenchmarkSQL查看OceanBase 的执行计划

一、什么是BenchmarkSQL

在这里插入图片描述

BenchmarkSQL是一个开源的数据库基准测试工具,可以用来评估数据库系统的性能,支持多种常见的数据库系统,包括EnterpriseDB、PostgreSQL、Oracle、Sybase、SQL Server、MySQL、HsqlDB、Derby/JavaDB和FireBird等。它的官网是:https://sourceforge.net/projects/benchmarksql/。

在国内的生产实践中,外键约束已经较少使用,但BenchmarkSQL的实现仍然广泛采用了外键约束,以符合TPC-C的要求。它的Order逻辑由4个SELECT、3个INSERT、2个UPDATE组成,和在微服务中不用匿名块和存储过程实现的逻辑高度匹配。

二、下载BenchmarkSQL

  1. 点击此链接跳转官方网站下载:https://sourceforge.net/projects/benchmarksql/
    在这里插入图片描述

  2. 上传至linux
    在这里插入图片描述

    这里使用的传输工具为:SecureCRT9
    安装步骤见此文:SecureCRT9汉化版安装
    也可关注文末公众号:数据探索者007 回复01获取

  3. 减压文件

    [oceanbase@localhost ~]$ ls
    benchmarksql-5.0.zip  myoceanbase  mysql_test
    [oceanbase@localhost ~]$ unzip benchmarksql-5.0.zip 
    Archive:  benchmarksql-5.0.zip
    6036b15716cf8c142465ac8092d53a777d609684creating: benchmarksql-5.0/extracting: benchmarksql-5.0/.gitignore  inflating: benchmarksql-5.0/HOW-TO-RUN.txt  inflating: benchmarksql-5.0/README.md  inflating: benchmarksql-5.0/build.xml  creating: benchmarksql-5.0/doc/creating: benchmarksql-5.0/doc/src/inflating: benchmarksql-5.0/doc/src/TimedDriver.odt  creating: benchmarksql-5.0/lib/extracting: benchmarksql-5.0/lib/.gitignore  inflating: benchmarksql-5.0/lib/apache-log4j-extras-1.1.jar  creating: benchmarksql-5.0/lib/firebird/inflating: benchmarksql-5.0/lib/firebird/connector-api-1.5.jar  inflating: benchmarksql-5.0/lib/firebird/jaybird-2.2.9.jar  inflating: benchmarksql-5.0/lib/log4j-1.2.17.jar  creating: benchmarksql-5.0/lib/oracle/extracting: benchmarksql-5.0/lib/oracle/.gitignore  inflating: benchmarksql-5.0/lib/oracle/README.txt  creating: benchmarksql-5.0/lib/postgres/inflating: benchmarksql-5.0/lib/postgres/postgresql-9.3-1102.jdbc41.jar  creating: benchmarksql-5.0/run/extracting: benchmarksql-5.0/run/.gitignore  inflating: benchmarksql-5.0/run/funcs.sh  inflating: benchmarksql-5.0/run/generateGraphs.sh  inflating: benchmarksql-5.0/run/generateReport.sh  inflating: benchmarksql-5.0/run/log4j.properties  creating: benchmarksql-5.0/run/misc/inflating: benchmarksql-5.0/run/misc/blk_device_iops.R  inflating: benchmarksql-5.0/run/misc/blk_device_kbps.R  inflating: benchmarksql-5.0/run/misc/cpu_utilization.R  inflating: benchmarksql-5.0/run/misc/dirty_buffers.R  inflating: benchmarksql-5.0/run/misc/latency.R  inflating: benchmarksql-5.0/run/misc/net_device_iops.R  inflating: benchmarksql-5.0/run/misc/net_device_kbps.R  inflating: benchmarksql-5.0/run/misc/os_collector_linux.py  inflating: benchmarksql-5.0/run/misc/tpm_nopm.R  inflating: benchmarksql-5.0/run/props.fb  inflating: benchmarksql-5.0/run/props.ora  inflating: benchmarksql-5.0/run/props.pg  inflating: benchmarksql-5.0/run/runBenchmark.sh  inflating: benchmarksql-5.0/run/runDatabaseBuild.sh  inflating: benchmarksql-5.0/run/runDatabaseDestroy.sh  inflating: benchmarksql-5.0/run/runLoader.sh  inflating: benchmarksql-5.0/run/runSQL.sh  creating: benchmarksql-5.0/run/sql.common/inflating: benchmarksql-5.0/run/sql.common/buildFinish.sql  inflating: benchmarksql-5.0/run/sql.common/foreignKeys.sql  inflating: benchmarksql-5.0/run/sql.common/indexCreates.sql  inflating: benchmarksql-5.0/run/sql.common/indexDrops.sql  inflating: benchmarksql-5.0/run/sql.common/tableCreates.sql  inflating: benchmarksql-5.0/run/sql.common/tableDrops.sql  inflating: benchmarksql-5.0/run/sql.common/tableTruncates.sql  creating: benchmarksql-5.0/run/sql.firebird/inflating: benchmarksql-5.0/run/sql.firebird/extraHistID.sql  creating: benchmarksql-5.0/run/sql.oracle/inflating: benchmarksql-5.0/run/sql.oracle/extraHistID.sql  creating: benchmarksql-5.0/run/sql.postgres/inflating: benchmarksql-5.0/run/sql.postgres/buildFinish.sql  inflating: benchmarksql-5.0/run/sql.postgres/extraHistID.sql  inflating: benchmarksql-5.0/run/sql.postgres/tableCopies.sql  creating: benchmarksql-5.0/src/creating: benchmarksql-5.0/src/LoadData/inflating: benchmarksql-5.0/src/LoadData/LoadData.java  inflating: benchmarksql-5.0/src/LoadData/LoadDataWorker.java  creating: benchmarksql-5.0/src/OSCollector/inflating: benchmarksql-5.0/src/OSCollector/OSCollector.java  creating: benchmarksql-5.0/src/client/inflating: benchmarksql-5.0/src/client/jTPCC.java  inflating: benchmarksql-5.0/src/client/jTPCCConfig.java  inflating: benchmarksql-5.0/src/client/jTPCCConnection.java  inflating: benchmarksql-5.0/src/client/jTPCCRandom.java  inflating: benchmarksql-5.0/src/client/jTPCCTData.java  inflating: benchmarksql-5.0/src/client/jTPCCTerminal.java  inflating: benchmarksql-5.0/src/client/jTPCCUtil.java  creating: benchmarksql-5.0/src/jdbc/inflating: benchmarksql-5.0/src/jdbc/ExecJDBC.java  
    [oceanbase@localhost ~]$ ls
    benchmarksql-5.0  benchmarksql-5.0.zip  myoceanbase  mysql_test
    [oceanbase@localhost ~]$ 
    [oceanbase@localhost ~]$ tree benchmarksql-5.0
    benchmarksql-5.0
    ├── build.xml
    ├── doc
    │   └── src
    │       └── TimedDriver.odt
    ├── HOW-TO-RUN.txt
    ├── lib
    │   ├── apache-log4j-extras-1.1.jar
    │   ├── firebird
    │   │   ├── connector-api-1.5.jar
    │   │   └── jaybird-2.2.9.jar
    │   ├── log4j-1.2.17.jar
    │   ├── oracle
    │   │   └── README.txt
    │   └── postgres
    │       └── postgresql-9.3-1102.jdbc41.jar
    ├── README.md
    ├── run
    │   ├── funcs.sh
    │   ├── generateGraphs.sh
    │   ├── generateReport.sh
    │   ├── log4j.properties
    │   ├── misc
    │   │   ├── blk_device_iops.R
    │   │   ├── blk_device_kbps.R
    │   │   ├── cpu_utilization.R
    │   │   ├── dirty_buffers.R
    │   │   ├── latency.R
    │   │   ├── net_device_iops.R
    │   │   ├── net_device_kbps.R
    │   │   ├── os_collector_linux.py
    │   │   └── tpm_nopm.R
    │   ├── props.fb
    │   ├── props.ora
    │   ├── props.pg
    │   ├── runBenchmark.sh
    │   ├── runDatabaseBuild.sh
    │   ├── runDatabaseDestroy.sh
    │   ├── runLoader.sh
    │   ├── runSQL.sh
    │   ├── sql.common
    │   │   ├── buildFinish.sql
    │   │   ├── foreignKeys.sql
    │   │   ├── indexCreates.sql
    │   │   ├── indexDrops.sql
    │   │   ├── tableCreates.sql
    │   │   ├── tableDrops.sql
    │   │   └── tableTruncates.sql
    │   ├── sql.firebird
    │   │   └── extraHistID.sql
    │   ├── sql.oracle
    │   │   └── extraHistID.sql
    │   └── sql.postgres
    │       ├── buildFinish.sql
    │       ├── extraHistID.sql
    │       └── tableCopies.sql
    └── src├── client│   ├── jTPCCConfig.java│   ├── jTPCCConnection.java│   ├── jTPCC.java│   ├── jTPCCRandom.java│   ├── jTPCCTData.java│   ├── jTPCCTerminal.java│   └── jTPCCUtil.java├── jdbc│   └── ExecJDBC.java├── LoadData│   ├── LoadData.java│   └── LoadDataWorker.java└── OSCollector└── OSCollector.java17 directories, 54 files
    [oceanbase@localhost ~]$ 
    
  4. 配置BenchmarkSQL
    使用如下命令进入props.ora 文件进行配置

    [oceanbase@localhost ~]$ vi benchmarksql-5.0/run/props.ora 
    

    具体配置如下:

    db=oracle
    driver=com.alipay.oceanbase.obproxy.mysql.jdbc.Driver
    conn=jdbc:oceanbase://192.168.66.110:2881/benchmark_sql?useUnicode=true&characterEncoding=utf-8
    user=user01@t1
    password=rootrootwarehouses=1
    loadWorkers=4terminals=1
    //To run specified transactions per terminal- runMins must equal zero
    runTxnsPerTerminal=10
    //To run for specified minutes- runTxnsPerTerminal must equal zero
    runMins=0
    //Number of total transactions per minute
    limitTxnsPerMin=300//Set to true to run in 4.x compatible mode. Set to false to use the
    //entire configured database evenly.
    terminalWarehouseFixed=true//The following five values must add up to 100
    newOrderWeight=45
    paymentWeight=43
    orderStatusWeight=4
    deliveryWeight=4
    stockLevelWeight=4// Directory name to create for collecting detailed result data.
    // Comment this out to suppress.
    resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
    osCollectorScript=./misc/os_collector_linux.py
    osCollectorInterval=1
    //osCollectorSSHAddr=user@dbhost
    osCollectorDevices=net_eth0 blk_sda
    ~                                                                        
    ~                                                                        
    ~                                                                        
    ~                                                                        
    ~                                            
    

    在这里插入图片描述

三、使用BenchmarkSQL查看OceanBase 的执行计划

  1. 下载ant
    在这里插入图片描述
    设置ant环境

    [root@localhost ~]# vi ~/.bash_profile 
    [root@localhost ~]# source /etc/profile
    [root@localhost ~]# ant -version
    Apache Ant(TM) version 1.9.4 compiled on November 5 2018
    

    在这里插入图片描述
    在对应目录下编译BenchmarkSQL

    [oceanbase@localhost ~]$ cd benchmarksql-5.0
    [oceanbase@localhost benchmarksql-5.0]$ ant
    Buildfile: /home/oceanbase/benchmarksql-5.0/build.xmlinit:[mkdir] Created dir: /home/oceanbase/benchmarksql-5.0/buildcompile:[javac] Compiling 11 source files to /home/oceanbase/benchmarksql-5.0/builddist:[mkdir] Created dir: /home/oceanbase/benchmarksql-5.0/dist[jar] Building jar: /home/oceanbase/benchmarksql-5.0/dist/BenchmarkSQL-5.0.jarBUILD SUCCESSFUL
    Total time: 2 seconds
    
  2. 准备Oceanbase驱动文件
    下载 JDBC 驱动,BenchmarkSQL 是通过 JDBC 连接各个数据库的。此次 OceanBase 的测试租户是 MySQL 类型,所以需要把相关 Jar 包一并放入其中

    Oceanbase驱动文件
    在这里插入图片描述
    下载好后放在benchmarksql-5.0/lib/

  3. 创建建表sql文件
    benchmarksql-5.0/run/sql.common/目录下,使用如下语句:

    vi benchmarksql-5.0/run/sql.common/createTables.sql
    

    createTables.sql文件内容如下:

    CREATE TABLE students (id INT PRIMARY KEY,name VARCHAR(50),age INT,gender ENUM('Male', 'Female')
    );
    CREATE TABLE courses (id INT PRIMARY KEY,name VARCHAR(50)
    );
    CREATE TABLE student_courses (student_id INT,course_id INT,grade INT,FOREIGN KEY (student_id) REFERENCES students(id),FOREIGN KEY (course_id) REFERENCES courses(id)
    );
    
  4. 修改runSQL.sh文件

    [oceanbase@localhost ~]$ cd benchmarksql-5.0/run/
    [oceanbase@localhost run]$ pwd
    /home/oceanbase/benchmarksql-5.0/run
    [oceanbase@localhost run]$ cd
    [oceanbase@localhost ~]$ vi benchmarksql-5.0/run/runSQL.sh 
    [oceanbase@localhost ~]$ 
    
    source /home/oceanbase/benchmarksql-5.0/run/fu1ncs.sh $
    

    在这里插入图片描述

  5. 执行测试:

    [oceanbase@localhost run]$ sh runSQL.sh props.ora sql.common/createTables.sql
    # ------------------------------------------------------------
    # Loading SQL file sql.common/createTables.sql
    # ------------------------------------------------------------
    CREATE TABLE students (
    id INT PRIMARY KEY,
    name VARCHAR(50),
    age INT,
    gender ENUM('Male', 'Female')
    );
    CREATE TABLE courses (
    id INT PRIMARY KEY,
    name VARCHAR(50)
    );
    CREATE TABLE student_courses (
    student_id INT,
    course_id INT,
    grade INT,
    FOREIGN KEY (student_id) REFERENCES students(id),
    FOREIGN KEY (course_id) REFERENCES courses(id)
    );
    [oceanbase@localhost run]$ 
    [oceanbase@localhost run]$
    
    ./runBenchmark.sh props.ora
    

    在这里插入图片描述


更多精彩文章可扫码关注公主号查看:
在这里插入图片描述

这篇关于下载BenchmarkSQL并使用BenchmarkSQL查看OceanBase 的执行计划的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/803762

相关文章

Java Lambda表达式的使用详解

《JavaLambda表达式的使用详解》:本文主要介绍JavaLambda表达式的使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、前言二、Lambda表达式概述1. 什么是Lambda表达式?三、Lambda表达式的语法规则1. 无参数的Lambda表

Spring组件实例化扩展点之InstantiationAwareBeanPostProcessor使用场景解析

《Spring组件实例化扩展点之InstantiationAwareBeanPostProcessor使用场景解析》InstantiationAwareBeanPostProcessor是Spring... 目录一、什么是InstantiationAwareBeanPostProcessor?二、核心方法解

详解如何使用Python构建从数据到文档的自动化工作流

《详解如何使用Python构建从数据到文档的自动化工作流》这篇文章将通过真实工作场景拆解,为大家展示如何用Python构建自动化工作流,让工具代替人力完成这些数字苦力活,感兴趣的小伙伴可以跟随小编一起... 目录一、Excel处理:从数据搬运工到智能分析师二、PDF处理:文档工厂的智能生产线三、邮件自动化:

Spring @RequestMapping 注解及使用技巧详解

《Spring@RequestMapping注解及使用技巧详解》@RequestMapping是SpringMVC中定义请求映射规则的核心注解,用于将HTTP请求映射到Controller处理方法... 目录一、核心作用二、关键参数说明三、快捷组合注解四、动态路径参数(@PathVariable)五、匹配请

Java 枚举的基本使用方法及实际使用场景

《Java枚举的基本使用方法及实际使用场景》枚举是Java中一种特殊的类,用于定义一组固定的常量,枚举类型提供了更好的类型安全性和可读性,适用于需要定义一组有限且固定的值的场景,本文给大家介绍Jav... 目录一、什么是枚举?二、枚举的基本使用方法定义枚举三、实际使用场景代替常量状态机四、更多用法1.实现接

springboot项目中使用JOSN解析库的方法

《springboot项目中使用JOSN解析库的方法》JSON,全程是JavaScriptObjectNotation,是一种轻量级的数据交换格式,本文给大家介绍springboot项目中使用JOSN... 目录一、jsON解析简介二、Spring Boot项目中使用JSON解析1、pom.XML文件引入依

Java中的record使用详解

《Java中的record使用详解》record是Java14引入的一种新语法(在Java16中成为正式功能),用于定义不可变的数据类,这篇文章给大家介绍Java中的record相关知识,感兴趣的朋友... 目录1. 什么是 record?2. 基本语法3. record 的核心特性4. 使用场景5. 自定

Python使用Tkinter打造一个完整的桌面应用

《Python使用Tkinter打造一个完整的桌面应用》在Python生态中,Tkinter就像一把瑞士军刀,它没有花哨的特效,却能快速搭建出实用的图形界面,作为Python自带的标准库,无需安装即可... 目录一、界面搭建:像搭积木一样组合控件二、菜单系统:给应用装上“控制中枢”三、事件驱动:让界面“活”

C/C++ chrono简单使用场景示例详解

《C/C++chrono简单使用场景示例详解》:本文主要介绍C/C++chrono简单使用场景示例详解,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友... 目录chrono使用场景举例1 输出格式化字符串chrono使用场景China编程举例1 输出格式化字符串示

Python验证码识别方式(使用pytesseract库)

《Python验证码识别方式(使用pytesseract库)》:本文主要介绍Python验证码识别方式(使用pytesseract库),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全... 目录1、安装Tesseract-OCR2、在python中使用3、本地图片识别4、结合playwrigh