Subject Re: DB-Inserts slow after 5000 inserts (with select)
Author Jens Saathoff
Sorry!

This is the METADATA for the table:

SET SQL DIALECT 3;



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


CREATE GENERATOR GEN_PLAYER_ID;

CREATE TABLE PLAYER (
PLAYERID BIGINT NOT NULL,
PLAYERNAME VARCHAR(255) NOT NULL,
PROVIDER_ID INTEGER default -1 NOT NULL,
ISOWNPLAYER SMALLINT DEFAULT 0 NOT NULL,
TOURNEYREALSYMBOL SMALLINT DEFAULT 0 NOT NULL,
TOURNEYPMSYMBOL SMALLINT DEFAULT 0 NOT NULL,
CASHREALSYMBOL SMALLINT DEFAULT 0 NOT NULL,
CASHPMSYMBOL SMALLINT DEFAULT 0 NOT NULL
);




/******************************************************************************/
/*** Unique Constraints ***/
/******************************************************************************/

ALTER TABLE PLAYER ADD CONSTRAINT UNQ1_PLAYER UNIQUE (PLAYERID,
PLAYERNAME, PROVIDER_ID);


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

ALTER TABLE PLAYER ADD CONSTRAINT PK_PLAYER PRIMARY KEY (PLAYERID);


/******************************************************************************/
/*** Foreign Keys ***/
/******************************************************************************/

ALTER TABLE PLAYER ADD CONSTRAINT FK_PLAYER_PROVIDER FOREIGN KEY
(PROVIDER_ID) REFERENCES PROVIDER (PROVIDERID);


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


SET TERM ^ ;



/******************************************************************************/
/*** Triggers for tables ***/
/******************************************************************************/



/* Trigger: PLAYER_BI */
CREATE OR ALTER TRIGGER PLAYER_BI FOR PLAYER
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.PLAYERID IS NULL) THEN
NEW.PLAYERID = GEN_ID(GEN_PLAYER_ID,1);
END
^


SET TERM ; ^

2011/6/14 Jens Saathoff <jensesaat@...>:
> Hi!
>
> In my app i use firebird and the ibpp-c++-api for firebird. I'm
> importing data from files. There is an import-routine, that first
> checks if a row already exists.
>
> Example: SELECT id From PLAYER WHERE name='thename'
>
> If no record exists and the id returned is 0 i'm inserting the data.
>
> After 5000 inserts the inserts getting slow. I start with 2000 records
> in 10 seconds, after 5000 inserts it slows down to 100 records in 10
> seconds.
>
> Is the problem the select statement before?
>
> Any suggestions or ideas?
>
> Thank you very much!
>