Subject Re: [ib-support] Re: just if you are curious
Author Roberto Della Pasqua
OK, let's go with the benchs; resuming ib7 is 40% faster on selects than
fb1.5 beta2

table of 550,000 records, fresh restored with fb1.5beta2; this is the table:

SET SQL DIALECT 3;

CREATE GENERATOR GEN_MAIN_ID;
SET NAMES NONE;


/***************************************************************************
***/
/*** Tables
***/
/***************************************************************************
***/

CREATE TABLE MAIN (
ID INTEGER NOT NULL,
NICK VARCHAR(12),
EMAIL VARCHAR(50),
UOMO INTEGER,
ISCRITTO DATE,
NATO DATE,
SEGNO INTEGER,
REGIONE INTEGER,
PROVINCIA INTEGER,
LOCALITA INTEGER,
AMICO INTEGER,
PAROLE VARCHAR(250),
FOTOESISTE INTEGER,
FOTOURL VARCHAR(50),
COLCAPELLI INTEGER,
STICAPELLI INTEGER,
COLOCCHI INTEGER,
STIOCCHI INTEGER,
CORPO INTEGER,
ACCESSORI INTEGER,
CARATTERE INTEGER,
ARGOMENTO INTEGER,
FUMARE INTEGER,
FUMARETUTTO INTEGER,
BERE INTEGER,
UBRIACARMI INTEGER,
CUCINARE INTEGER,
CASA INTEGER,
SPESA INTEGER,
FIGLI INTEGER,
SHOPPING INTEGER,
AMICI INTEGER,
ORTO INTEGER,
ANIMALI INTEGER,
AMORE INTEGER,
ALLAMORE INTEGER,
MUSICA INTEGER,
GUIDARE INTEGER,
PUNTUALITA INTEGER,
STUDIARE INTEGER,
TV INTEGER,
COCCOLE INTEGER,
VIAGGIARE INTEGER,
RISTORARE INTEGER,
DISCOTECA INTEGER,
ARTE INTEGER,
COLLEZIONISMO INTEGER,
MUSEO INTEGER,
TEATRO INTEGER,
CONCERTI INTEGER,
CINEMA INTEGER,
INTERNET INTEGER,
VOLONTARIATO INTEGER,
LEGGERE INTEGER,
NATURA INTEGER,
MONTAGNA INTEGER,
CAMPEGGIO INTEGER,
POLITICA INTEGER,
MODA INTEGER,
VIDEOGIOCHI INTEGER,
MARE INTEGER,
PUB INTEGER,
PWD VARCHAR(12)
);





/***************************************************************************
***/
/*** Primary Keys
***/
/***************************************************************************
***/

ALTER TABLE MAIN ADD CONSTRAINT PK_MAIN PRIMARY KEY (ID);


/***************************************************************************
***/
/*** Indices
***/
/***************************************************************************
***/

CREATE INDEX IDX_ACCESSORI ON MAIN (ACCESSORI);
CREATE INDEX IDX_ALLAMORE ON MAIN (ALLAMORE);
CREATE INDEX IDX_AMICI ON MAIN (AMICI);
CREATE INDEX IDX_AMICO ON MAIN (AMICO);
CREATE INDEX IDX_AMORE ON MAIN (AMORE);
CREATE INDEX IDX_ANIMALI ON MAIN (ANIMALI);
CREATE INDEX IDX_ARGOMENTI ON MAIN (ARGOMENTO);
CREATE INDEX IDX_ARTE ON MAIN (ARTE);
CREATE INDEX IDX_BERE ON MAIN (BERE);
CREATE INDEX IDX_CAMPEGGIO ON MAIN (CAMPEGGIO);
CREATE INDEX IDX_CARATTERE ON MAIN (CARATTERE);
CREATE INDEX IDX_CASA ON MAIN (CASA);
CREATE INDEX IDX_CINEMA ON MAIN (CINEMA);
CREATE INDEX IDX_COCCOLE ON MAIN (COCCOLE);
CREATE INDEX IDX_COLCAPELLI ON MAIN (COLCAPELLI);
CREATE INDEX IDX_COLLEZIONISMO ON MAIN (COLLEZIONISMO);
CREATE INDEX IDX_COLOCCHI ON MAIN (COLOCCHI);
CREATE INDEX IDX_CONCERTI ON MAIN (CONCERTI);
CREATE INDEX IDX_CORPO ON MAIN (CORPO);
CREATE INDEX IDX_CUCINARE ON MAIN (CUCINARE);
CREATE INDEX IDX_DISCOTECA ON MAIN (DISCOTECA);
CREATE INDEX IDX_EMAIL ON MAIN (EMAIL);
CREATE INDEX IDX_FIGLI ON MAIN (FIGLI);
CREATE INDEX IDX_FOTOESISTE ON MAIN (FOTOESISTE);
CREATE INDEX IDX_FUMARE ON MAIN (FUMARE);
CREATE INDEX IDX_FUMARETUTTO ON MAIN (FUMARETUTTO);
CREATE INDEX IDX_GUIDARE ON MAIN (GUIDARE);
CREATE INDEX IDX_INTERNET ON MAIN (INTERNET);
CREATE INDEX IDX_ISCRITTO ON MAIN (ISCRITTO);
CREATE INDEX IDX_LEGGERE ON MAIN (LEGGERE);
CREATE INDEX IDX_LOCALITA ON MAIN (LOCALITA);
CREATE DESCENDING INDEX IDX_MAIN ON MAIN (ID);
CREATE INDEX IDX_MARE ON MAIN (MARE);
CREATE INDEX IDX_MODA ON MAIN (MODA);
CREATE INDEX IDX_MONTAGNA ON MAIN (MONTAGNA);
CREATE INDEX IDX_MUSEO ON MAIN (MUSEO);
CREATE INDEX IDX_MUSICA ON MAIN (MUSICA);
CREATE INDEX IDX_NATO ON MAIN (NATO);
CREATE INDEX IDX_NATURA ON MAIN (NATURA);
CREATE INDEX IDX_NICK ON MAIN (NICK);
CREATE INDEX IDX_ORTO ON MAIN (ORTO);
CREATE INDEX IDX_POLITICA ON MAIN (POLITICA);
CREATE INDEX IDX_PROVINCIA ON MAIN (PROVINCIA);
CREATE INDEX IDX_PUB ON MAIN (PUB);
CREATE INDEX IDX_PUNTUALITA ON MAIN (PUNTUALITA);
CREATE INDEX IDX_REGIONE ON MAIN (REGIONE);
CREATE INDEX IDX_RISTORARE ON MAIN (RISTORARE);
CREATE INDEX IDX_SEGNO ON MAIN (SEGNO);
CREATE INDEX IDX_SHOPPING ON MAIN (SHOPPING);
CREATE INDEX IDX_SPESA ON MAIN (SPESA);
CREATE INDEX IDX_STICAPELLI ON MAIN (STICAPELLI);
CREATE INDEX IDX_STIOCCHI ON MAIN (STIOCCHI);
CREATE INDEX IDX_STUDIARE ON MAIN (STUDIARE);
CREATE INDEX IDX_TEATRO ON MAIN (TEATRO);
CREATE INDEX IDX_TV ON MAIN (TV);
CREATE INDEX IDX_UBRIACARMI ON MAIN (UBRIACARMI);
CREATE INDEX IDX_UOMO ON MAIN (UOMO);
CREATE INDEX IDX_VIAGGIARE ON MAIN (VIAGGIARE);
CREATE INDEX IDX_VIDEOGIOCHI ON MAIN (VIDEOGIOCHI);
CREATE INDEX IDX_VOLONTARIATO ON MAIN (VOLONTARIATO);


/***************************************************************************
***/
/*** Triggers
***/
/***************************************************************************
***/


SET TERM ^ ;




/* Trigger: MAIN_BI */
CREATE TRIGGER MAIN_BI FOR MAIN
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.ID IS NULL) THEN
NEW.ID = GEN_ID(GEN_MAIN_ID,1);
END
^


SET TERM ; ^


----------------------------------------------------------------------------
------------------
This code produce 1000 random queries, so to avoid too much cache behavior.
function randomSQL: string;
var fields: array[0..50] of string;
I: Integer;
logic: array[0..1] of string;
begin
Result := 'SELECT * FROM MAIN WHERE ';
fields[0] := 'FUMARE';
fields[1] := 'FUMARETUTTO';
fields[2] := 'BERE';
fields[3] := 'UBRIACARMI';
fields[4] := 'CUCINARE';
fields[5] := 'CASA';
fields[6] := 'SPESA';
fields[7] := 'FIGLI';
fields[8] := 'SHOPPING';
fields[9] := 'AMICI';
fields[10] := 'ORTO';
fields[11] := 'ANIMALI';
fields[12] := 'AMORE';
fields[13] := 'ALLAMORE';
fields[14] := 'MUSICA';
fields[15] := 'GUIDARE';
fields[16] := 'PUNTUALITA';
fields[17] := 'STUDIARE';
fields[18] := 'TV';
fields[19] := 'COCCOLE';
fields[20] := 'VIAGGIARE';
fields[21] := 'RISTORARE';
fields[22] := 'DISCOTECA';
fields[23] := 'ARTE';
fields[24] := 'COLLEZIONISMO';
fields[25] := 'MUSEO';
fields[26] := 'TEATRO';
fields[27] := 'CONCERTI';
fields[28] := 'CINEMA';
fields[29] := 'INTERNET';
fields[30] := 'VOLONTARIATO';
fields[31] := 'LEGGERE';
fields[32] := 'NATURA';
fields[33] := 'MONTAGNA';
fields[34] := 'CAMPEGGIO';
fields[35] := 'POLITICA';
fields[36] := 'MODA';
fields[37] := 'VIDEOGIOCHI';
fields[38] := 'MARE';
fields[39] := 'PUB';
logic[0] := 'AND';
logic[1] := 'OR';

Result := Result + 'UOMO=' + IntToStr(RandomBool) + ' AND LOCALITA=' +
IntToStr(Random(12)) + ' AND ';

for I := 1 to Random(50) do // Iterate
begin
Result := Result + fields[random(39)] + '=' + IntToStr(RandomBool) + #32
+ logic[RandomBool] + #32;
end; // for
SetLength(Result, Length(Result) - 4);
Result := Result + ' ORDER BY ID DESC';
end;

procedure TForm1.Button3Click(Sender: TObject);
var sql: string;
I: Integer;
begin
Randomize;



for I := 1 to 1000 do // Iterate
begin
sql := randomSQL;
Memo1.Lines.add(sql);
IBTransaction1.StartTransaction;
IBSQL1.SQL.Clear;
IBSQL1.SQL.Add(Double39(sql));
IBSQL1.Prepare;
IBSQL1.ExecQuery;
IBTransaction1.Commit;

end; // for


end;
------------------
Here the results:
1) www.dellapasqua.com/fb15beta2.txt here the 1000 random queries on the
table
2) www.dellapasqua.com/ib7.txt here the 1000 random queries on the table
3) www.dellapasqua.com/fb15beta2.gif 3,9 msec of average time
4) www.dellapasqua.com/ib7.gif 2,8 msec average time

SeeYa boys :D
Btw... I forgot....I go out and buy IB7 :))) LOL
Kidding apart, IMHO it's alright that the commercial version of IB is
faster...so don't worry about this 40% performance difference at all!

Robi