INSERT/UPDATE/DELETE テスト
Firebird 2.5、3.0、4.0 上、INSERT・UPDATE・DELETE のスループットを測定するシングルスレッドの SQL ベンチマークです。結果は主にディスク、CPU、RAM、Firebird のキャッシュサイズに依存します。簡単なハードウェアチェックとしてお使いください。優れたハードウェアは通常、公開結果の上位 30% に位置します。
公開結果
テストの実行方法
- 以下の SQL スクリプトをファイルにコピーします。例:
c:\temp\dml-basic-benchmark.sql(Linux:/tmp/dml-basic-benchmark.sql)。 - 最初の
create database行でデータベースパスを変更します。サンプルは Firebird 3 TCP(localhost:e:\inserttest4.fdb)を使用しています。XNET(xnet://Disk:\path\database.fdb)または組み込み(disk:\path\database.fdb)に切り替えることもできます。 - 本番環境で使用しているものと同じ
firebird.confを維持します。最初にチューニングするには、最適化された構成を使用してください。 isqlを実行します(一部の Linux パッケージでは:isql-fb)。テストでは、複数のインデックスを持つテーブルを作成し、100 万回の INSERT、UPDATE、DELETE 操作を実行します。- データベースは約 3.6 GB に成長します - テスト後は削除してください。
isql コマンド
Windows
isql -i c:\temp\dml-basic-benchmark.sql
Linux
isql -i /tmp/dml-basic-benchmark.sql
テスト SQL スクリプト
.sql ファイルにコピーし、必要に応じて接続文字列と SYSDBA パスワードを編集します。
create database "localhost:e:\inserttest4.fdb" user "SYSDBA" password "masterkey" page_size 16384;set term ^; execute block as begin – ###################################################### rdb$set_context(‘USER_SESSION’, ‘ROWS_TO_HANDLE’, 1000000); – ###################################################### execute statement ‘drop sequence g’; when any do begin end end ^ set term ;^ commit;
create sequence g;
recreate table test( id int ,grp smallint ,pid int ,dts timestamp ,code_sml varchar(15) ,code_med varchar(150) ,code_lrg varchar(1500) ,code_unq char(16) character set octets ,constraint test_pk primary key(id) ,constraint test_unq unique( code_unq ) );
create index test_pid on test(pid); create descending index test_dts on test(dts); create index test_dml on test(code_sml); create index test_med on test(code_med); create index test_lrg on test(code_lrg); commit;
set bail on; set list on; set stat on;
set term ^; execute block returns( inserted_rows int, elap_ms int ) as declare i int = 0; declare t timestamp; begin inserted_rows = rdb$get_context(‘USER_SESSION’, ‘ROWS_TO_HANDLE’); t = ’now’; while ( i < inserted_rows ) do begin insert into test(id, grp, pid, dts, code_sml, code_med, code_lrg, code_unq) values( gen_id(g,1) ,rand() * 10 ,rand() * 1000 ,dateadd( rand()*1000000 second to timestamp ‘01.01.2019 00:00:00’ ) ,lpad(’’, 15, ‘QWERTY’ ) ,lpad(’’, 150, ‘QWERTY’ ) ,lpad(’’, 1500, ‘QWERTY’ ) ,gen_uuid() ); i = i + 1; end elap_ms = datediff(millisecond from t to cast(’now’ as timestamp)); suspend; end ^ commit^
execute block returns( updated_rows int, elap_ms int ) as declare i int = 0; declare t timestamp; begin updated_rows = rdb$get_context(‘USER_SESSION’, ‘ROWS_TO_HANDLE’); t = ’now’; while ( i < updated_rows ) do begin update test set grp = rand() * 10 ,pid = rand() * 1000 ,dts = dateadd( rand()*100000 second to timestamp ‘01.01.2019 00:00:00’ ) ,code_sml = lpad(’’, 15, ‘ASDFGH’ ) ,code_med = lpad(’’, 150, ‘ASDFGH’ ) ,code_lrg = lpad(’’, 1500, ‘ASDFGH’ ) ,code_unq = gen_uuid() where id = :i+1 ; i = i + 1; end elap_ms = datediff(millisecond from t to cast(’now’ as timestamp)); suspend; end ^
commit^
execute block returns( deleted_rows int, elap_ms int ) as declare i int = 0; declare t timestamp; begin deleted_rows = rdb$get_context(‘USER_SESSION’, ‘ROWS_TO_HANDLE’); t = ’now’; while ( i < deleted_rows ) do begin delete from test where id = :i+1 ; i = i + 1; end elap_ms = datediff(millisecond from t to cast(’now’ as timestamp)); suspend; end ^
set term ;^ commit;