Fast check for existing rows

From: Timo Nentwig (tcn_at_spamgourmet.com)
Date: 02/17/04


Date: Tue, 17 Feb 2004 12:35:11 +0100

Hi!

I extract word from a lot of long texts and insert them into a table - each
word only once.

What is the fastest method in order to check whether the word already is in
database?

1) auto-commit is that slow that it must be disabled
2) a SELECT prior to the INSERT also is extraordinary slow
3) adding a unique key and catching the exception is
        a) slow as well :)
        b) in case of Postgres the entire transaction is rolled back (see 1).
        c) the exception may have other causes, too..

Any solution to this problem?

TIA
Timo