I have a performance problem with if I am understanding correctly unique
(secondary) indexes (or indices) when using the MVStore. It is very
apparent because I am running a bulk process inserting 100000s of rows and
it slows to a crawl on some tables, and I believe it is because of the
unique checking. In particular the code below, it seems to make the
assumption that the inserted values will be monotonically increasing and so
it can just iterate through after a latest entry, but for me I find it
iterating 1000s of times per insert.

Is there no way to do this with a map lookup? I am wary that I may be
misunderstanding things because it does seem to be like quite a large
oversight.

regards,

Mike

    private void checkUnique(SearchRow row, TransactionMap<Value, Value>
map, ValueArray unique) {
        Iterator<Value> it = map.keyIterator(unique, true);
        while (it.hasNext()) {
            ValueArray k = (ValueArray) it.next();
            SearchRow r2 = convertToSearchRow(k);
            if (compareRows(row, r2) != 0) {
                break;
            }
            if (map.get(k) != null) {
                if (!containsNullAndAllowMultipleNull(r2)) {
                    throw getDuplicateKeyException(k.toString());
                }
            }
        }
    }

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to