Subject Re: [firebird-support] Insertion speed
Author Gary Benade
> Thanks for all the help and tips. I have to admit that my simple query
> wasn't quite as simple as originally stated. What it was trying to
> achieve
> was something like this
> FOR
> SELECT BP.BUYER_NO
> FROM BUYERPUBLICATION BP
> WHERE BP.PUBLICATION_NO = :PUBLICATION_NO
> AND NOT EXISTS(SELECT IM.BUYER_NO
> FROM ISSUESMAILED IM
> WHERE IM.BUYER_NO = BP.BUYER_NO
> AND IM.ISSUE_NO = :ISSUE_NO)
> INTO :BUYER_NO
> DO
> BEGIN
> //INSERT BUYER_NO INTO OTHER TABLE
> END

change to this and see if there is an improvement. Helen pointed it out to
me once and it made a huge difference (still not 100% sure why). BTW. is
there an index on ISSUESMAILED( BUYER_NO) and/or ISSUESMAILED( ISSUE_NO)

FOR
SELECT BP.BUYER_NO
FROM BUYERPUBLICATION BP
WHERE BP.PUBLICATION_NO = :PUBLICATION_NO
AND NOT EXISTS(SELECT 1
FROM ISSUESMAILED IM
WHERE IM.BUYER_NO = BP.BUYER_NO
AND IM.ISSUE_NO = :ISSUE_NO)
INTO :BUYER_NO
DO
BEGIN
//INSERT BUYER_NO INTO OTHER TABLE
END