mysql生成千萬級測試資料

2021-08-08 16:40:44 字數 918 閱讀 9726

mysql生成千萬級測試資料

為了更好的測試mysql效能以及程式優化,不得不去製作海量資料來測試。

之前用儲存過程的方法。生成測試資料。特別慢。

所以改為在服務端呼叫db生成

1.首先建立測試表(card表)

create table `card` (

`card_id` bigint(20) not null auto_increment comment 'id',

`card_number` varchar(100) default null comment '卡號',

primary key (`card_id`)

) engine=myisam auto_increment=0 default charset=utf8 checksum=1 delay_key_write=1 row_format=dynamic

2.

<?php

ini_set('max_execution_time', '0');    //mysql執行時間

@mysql_pconnect("localhost","root","root") or die('connect failed');

@mysql_select_db("test") or die('select db failed');

//這一步很重要  取消mysql的自動提交

mysql_query('set autocommit=0;');

mysql_query('set names utf8');

$begin = time();

$count = 1;

for($i=1;$i<=10000000;$i++)

}$end = time();

echo "用時 ".($end-$begin)." 秒 ";

快速生成千萬條mysql資料

學習 測試mysql海量資料的場景,需要先生成資料。mysql官方文件說得很清楚。load data infile 匯入資料比insert要快20倍。所以我們先生成一千萬條資料的檔案。然後將資料匯入表中。假如有個使用者表 id,username,password,age,id是自動增長,我們現在需要...

KKB MySQL建立千萬測試資料

這編部落格主要就是演示如何建立一千萬條資料載入到資料庫的表中,方便後面的sql優化的學習 進入主題 建立表 create table users id int 11 notnull auto increment name varchar 30 not null email varchar 30 de...

測試資料生成

目的 sql server 搭建日誌傳輸,模擬災難轉移,在主庫上不斷生成測試資料,模擬生產環境。生成測試資料指令碼 表結構 if table dbo.t1 exists,then drop it if object id dbo.t1 u is not null drop table dbo.t1 ...