|
感受佳:DM数据库的插入速度是MySQL的10倍以上;
待改进:DM数据库的文档还是过少,遇到问题很难排查。
DM数据库管理系统v7.1测试
1、新建数据库实例
数据库控制文件:dmdbms\data\dm_test\dm.ctl
数据文件:dmdbms\data\dm_test\SYSTEM.DBF,
dmdbms\data\dm_test\ROLL.DBF,
dmdbms\data\dm_test\TEMP.DBF,
dmdbms\data\dm_test\MAIN.DBF
日志文件:dmdbms\data\dm_test\dm_test01.log
dmdbms\data\dm_test\dm_test02.log
2、DM的Web服务器
输入http://localhost:8080/isql,
3、测试实战
3.1、测试的MySQL脚本:- CREATE DATABASE /*!32312 if not exists*/`dm_test` /*!40100 default character set utf8 */;
- USE `dm_test`;
- DROP TABLE IF EXISTS `contacts`;
- CREATE TABLE `contacts` (
- `contact_id` VARCHAR(40) NOT NULL,
- `password` VARCHAR(40) NOT NULL,
- `first_name` VARCHAR(40) NOT NULL,
- `last_name` VARCHAR(60) NOT NULL,
- `company_name` VARCHAR(60) DEFAULT NULL,
- `email` VARCHAR(255) DEFAULT NULL,
- `created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (`contact_id`)
- ) ENGINE=INNODB DEFAULT CHARSET=utf8;
- DROP TABLE IF EXISTS `orders`;
- CREATE TABLE `orders` (
- `order_id` INT(11) NOT NULL AUTO_INCREMENT,
- `contact_id` VARCHAR(40) NOT NULL,
- `product` VARCHAR(40) NOT NULL,
- `quantity` INT(11) NOT NULL,
- `price` DOUBLE NOT NULL,
- `status` VARCHAR(20) NOT NULL DEFAULT 'unverified',
- `created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (`order_id`),
- KEY `contact_id` (`contact_id`),
- CONSTRAINT `orders_ibfk_1` FOREIGN KEY (`contact_id`) REFERENCES `contacts` (`contact_id`) ON DELETE CASCADE ON UPDATE CASCADE
- ) ENGINE=INNODB DEFAULT CHARSET=utf8;
- DROP TABLE IF EXISTS `support`;
- CREATE TABLE `support` (
- `support_id` INT(11) NOT NULL AUTO_INCREMENT,
- `contact_id` VARCHAR(40) NOT NULL,
- `code` VARCHAR(10) NOT NULL,
- `status` VARCHAR(20) NOT NULL,
- `phone` VARCHAR(20) DEFAULT NULL,
- `email` VARCHAR(255) DEFAULT NULL,
- `request` VARCHAR(255) NOT NULL,
- `created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (`support_id`),
- KEY `contact_id` (`contact_id`),
- CONSTRAINT `support_ibfk_1` FOREIGN KEY (`contact_id`) REFERENCES `contacts` (`contact_id`) ON DELETE CASCADE ON UPDATE CASCADE
- ) ENGINE=INNODB DEFAULT CHARSET=utf8;
复制代码 3.2、在达梦DM管理工具下,执行:- --创建表空间
- CREATE TABLESPACE dm_test DATAFILE 'dm_test.DBF' size 60;
- --创建模式
- CREATE SCHEMA business;
- --创建表
- --CREATE business.contacts
- create table business.contacts
- (
- contact_id VARCHAR(40) NOT NULL PRIMARY KEY,
- password VARCHAR(40) NOT NULL,
- first_name VARCHAR(40) NOT NULL,
- last_name VARCHAR(60) NOT NULL,
- company_name VARCHAR(60) DEFAULT NULL,
- email VARCHAR(255) DEFAULT NULL,
- created TIMESTAMP NOT NULL
- ) STORAGE (on dm_test);
- --创建表
- --CREATE business.orders
- create TABLE business.orders
- (
- order_id INT IDENTITY(1,1) PRIMARY KEY,
- contact_id VARCHAR(40) NOT NULL REFERENCES business.contacts(contact_id),
- product VARCHAR(40) NOT NULL,
- quantity INT NOT NULL,
- price DECIMAL(10,2) NOT NULL,
- status VARCHAR(20) NOT NULL default 'unverified',
- created TIMESTAMP NOT NULL
- ) STORAGE(ON "DM_TEST", CLUSTERBTR);
- --创建表
- --CREATE business.support
- create TABLE business.support
- (
- support_id INT IDENTITY(1,1) PRIMARY KEY,
- contact_id VARCHAR(40) NOT NULL REFERENCES business.contacts(contact_id),
- code VARCHAR(10) NOT NULL,
- status VARCHAR(20) NOT NULL,
- phone VARCHAR(20) DEFAULT NULL,
- email VARCHAR(255) DEFAULT NULL,
- request VARCHAR(255) NOT NULL,
- created TIMESTAMP NOT NULL
- ) STORAGE(ON "DM_TEST", CLUSTERBTR);
复制代码 3.3、MySQL测试程序如下:- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
- import java.util.Date;
- public class MySQLtest {
- private static String driver = "com.mysql.jdbc.Driver";
- private static String db_url = "jdbc:mysql://localhost:3306/dm_test?characterEncoding=utf8";
- private static String user = "ccesengine";
- private static String password = "NAVE-LEX9";
- public void insertTest(int times) throws SQLException {
- PreparedStatement stmt = null;
- Connection conn = null;
- try {
- Class.forName(driver);
- conn = DriverManager.getConnection(db_url, user, password);
- String sql = "INSERT INTO contacts(contact_id,password,first_name,last_name,company_name,email,created) VALUES(?,?,?,?,?,?,?)";
-
- for(int i=0; i<times; i++){
- stmt = conn.prepareStatement(sql);
-
- String contact_id = Utils.randomNumeric(40);
- String password = Utils.randomString(40);
- String first_name = Utils.randomString(40);
- String last_name = Utils.randomString(60);
- String company_name = Utils.randomString(60);
- String email = Utils.randomString(14) + "@sina.com.cn";
- java.sql.Timestamp created = new java.sql.Timestamp(new Date().getTime());
-
- stmt.setString(1, contact_id);
- stmt.setString(2, password);
- stmt.setString(3, first_name);
- stmt.setString(4, last_name);
- stmt.setString(5, company_name);
- stmt.setString(6, email);
- stmt.setTimestamp(7, created);
- stmt.executeUpdate();
- }
- } catch (Exception e) {
- System.err.println("Error: " + e.getMessage());
- e.printStackTrace();
- } finally {
- stmt.close();
- conn.close();
- }
- }
-
- public static void main(String[] args) throws SQLException{
- MySQLtest test = new MySQLtest();
- long d1 = new Date().getTime();
- test.insertTest(100);
- long d2 = new Date().getTime();
- System.out.println("插入100条记录所需的时间为: " + (d2-d1) + "毫秒");
- long d3 = new Date().getTime();
- test.insertTest(1000);
- long d4 = new Date().getTime();
- System.out.println("插入1000条记录所需的时间为: " + (d4-d3) + "毫秒");
- long d5 = new Date().getTime();
- test.insertTest(5000);
- long d6 = new Date().getTime();
- System.out.println("插入5000条记录所需的时间为: " + (d6-d5) + "毫秒");
- }
- }
复制代码 3.4、DM数据库测试程序如下:- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
- import java.util.Date;
- public class DMtest {
- private static String driver = "dm7.jdbc.driver.DmDriver";
- private static String db_url = "jdbc:dm://localhost:5236";
- private static String user = "SYSDBA";
- private static String password = "adminadmin";
-
- public void insertTest(int times) throws SQLException {
- PreparedStatement stmt = null;
- Connection conn = null;
- try {
- Class.forName(driver);
- try {
- conn = DriverManager.getConnection(db_url, user, password);
- } catch (SQLException e) {
- throw new SQLException("Connect to DM Server Error : "
- + e.getMessage());
- }
- String sql = "INSERT INTO business.contacts(contact_id,password,first_name,last_name,company_name,email,created) VALUES(?,?,?,?,?,?,?)";
-
- for(int i=0; i<times; i++){
- stmt = conn.prepareStatement(sql);
-
- String contact_id = Utils.randomNumeric(40);
- String password = Utils.randomString(40);
- String first_name = Utils.randomString(40);
- String last_name = Utils.randomString(60);
- String company_name = Utils.randomString(60);
- String email = Utils.randomString(14) + "@sina.com.cn";
- java.sql.Timestamp created = new java.sql.Timestamp(new java.util.Date().getTime());
-
- stmt.setString(1, contact_id);
- stmt.setString(2, password);
- stmt.setString(3, first_name);
- stmt.setString(4, last_name);
- stmt.setString(5, company_name);
- stmt.setString(6, email);
- stmt.setTimestamp(7, created);
- stmt.executeUpdate();
- }
- } catch (Exception e) {
- System.err.println("Error: " + e.getMessage());
- e.printStackTrace();
- } finally {
- stmt.close();
- conn.close();
- }
- }
-
- public static void main(String[] args) throws SQLException{
- DMtest test = new DMtest();
- long d1 = new Date().getTime();
- test.insertTest(1);
- long d2 = new Date().getTime();
- System.out.println("插入100条记录所需的时间为: " + (d2-d1) + "毫秒");
- long d3 = new Date().getTime();
- test.insertTest(1000);
- long d4 = new Date().getTime();
- System.out.println("插入1000条记录所需的时间为: " + (d4-d3) + "毫秒");
- long d5 = new Date().getTime();
- test.insertTest(5000);
- long d6 = new Date().getTime();
- System.out.println("插入5000条记录所需的时间为: " + (d6-d5) + "毫秒");
- }
- }
复制代码 3.5、比较条件
1、软件版本
达梦数据库:DM v7.1
MySQL:5.1.53 community 32位
2、其它
其它软硬件相同,在同一台台式机,Windows XP操作系统上运行。MySQL安装配置为开发机,未做优化。
3.6、测试结果:
3.7、结论:
感受佳:DM数据库的插入速度是MySQL的10倍以上;
待改进:DM数据库的文档还是过少,遇到问题很难排查。
比如我遇到的问题:String urlString = "jdbc:dm7://localhost:5236" 连接不上。直到达梦的高人告诉我,DM7为了向下兼容DM6,连接又改回了String urlString = "jdbc:dm://localhost:5236" 。可惜文档没有更新,如果没人指点,我就进行不下去了。
我只是粗略地进行了个测试,大家看了后可以对DM数据库有个稍微理性的认识。国产数据库其实做得很好! |
|