Questa pagina è stata tradotta automaticamente. Leggi l'originale in inglese. English

Di seguito puoi trovare un test molto semplice (in puro SQL) che misura le prestazioni delle operazioni INSERT/UPDATE/DELETE in Firebird (4.0, 3.0 e 2.5). Questo test è single-threaded e il suo risultato dipende principalmente dall’hardware (velocità del disco, CPU, RAM) e dalla dimensione della cache di Firebird. Usa questo test per valutare rapidamente il tuo hardware e le prestazioni di Firebird e confrontali con i risultati qui sotto: un buon hardware dovrebbe essere nel 30% superiore della tabella.

Vedi come eseguire il test »

Per favore invia a [email protected] il risultato dell’esecuzione dello script con i dettagli sul tuo disco, CPU e RAM, e lo aggiungeremo alla tabella qui sotto.

Ecco il grafico e il file XLS con i risultati dei test su diversi dischi, versioni di Firebird e computer:

Risultati del test INSERT/UPDATE/DELETE

Scarica il file XLS con i risultati dei test qui.

Script SQL del test

Per eseguire il test, copia-incolla il testo qui sotto in un file di testo e cambia il percorso del database - nell’esempio, la stringa di connessione è in formato TCP di Firebird 3, ma puoi cambiarla in XNET (xnet://Disk:\path\database.fdb) o embedded (disk:\path\database.fdb).

Per favore usa lo stesso firebird.conf che usi normalmente (se devi ottimizzare la tua configurazione, usa uno di questi file di configurazione ottimizzati).

Questo test crea un database, crea una tabella con diversi indici, e poi esegue 1 milione di operazioni INSERT, UPDATE e DELETE.

Se hai salvato il file SQL in c:\temp\dml-basic-benchmark.sql, esegui questo script con il seguente comando:

Code
isql -i c:\temp\dml-basic-benchmark.sql

Questo script creerà un database di circa 3.6Gb. Non dimenticare di eliminarlo dopo il test.

Code
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;