Re: Possible to prevent transaction abort?

Поиск
Список
Период
Сортировка
От Adam B
Тема Re: Possible to prevent transaction abort?
Дата
Msg-id 49FB62B8.1050801@videx.com
обсуждение исходный текст
Ответ на Re: Possible to prevent transaction abort?  (Thomas Kellerer <spam_eater@gmx.net>)
Ответы Re: Possible to prevent transaction abort?  (Thomas Kellerer <spam_eater@gmx.net>)
Список pgsql-general
Perhaps I'm doing something wrong.  I'm consistently taking over 20s for
the following test case.  (Without savepoints it takes under 10s)

CREATE TABLE lots2
(
  lid serial NOT NULL,
  "name" character varying(64),
  CONSTRAINT lots2pk PRIMARY KEY (lid),
  CONSTRAINT lots2_unique_name UNIQUE (name)
)

Java code:

            Connection con =
DriverManager.getConnection("jdbc:postgresql://localhost/driver_test",
"postgres", "*****");

            Statement st = con.createStatement();
            st.executeUpdate("DELETE FROM lots2");
            st.close();

            con.setAutoCommit(false);

            PreparedStatement ps = con.prepareStatement("INSERT INTO
lots2 (name) VALUES (?)");

            long start = System.currentTimeMillis();
            for (int i = 0; i < 100000; i++)
            {
                ps.setString(1, "number " + i);
                Savepoint saved = con.setSavepoint();
                ps.executeUpdate();
                con.releaseSavepoint(saved);
            }

            con.setAutoCommit(true);
            long stop = System.currentTimeMillis();
            System.out.println((stop - start) + "ms");



Thomas Kellerer wrote:
> Adam B wrote on 01.05.2009 19:50:
>> I realize that I could set a save-point before every INSERT but that
>> nearly doubles the processing time.
>
> That's interesting.
>
> I did a quick test with JDBC inserting 500,000 rows and the time when
> using a savepoint for each INSERT was not really different to the one
> when not using a savepoint (less than a second which could well be
> caused by other things in the system).
>
> I tested this locally so no real network traffic involved, which might
> change the timing as more stuff is sent over to the server when using
> the savepoint.
>
> Thomas
>
>



Videx Inc. 1105 N. E. Circle Blvd. Corvallis OR 97330 (541) 758-0521
CONFIDENTIAL COMMUNICATION: The email message and any attachments are intended only for the addressee.  They may be
privileged,confidential, and protected from disclosure. If you are not the intended recipient, any dissemination,
distribution,or copying is expressly prohibited.  If you received this email message in error, please notify the sender
immediatelyby replying to this e-mail message or by telephone 


В списке pgsql-general по дате отправления:

Предыдущее
От: Thomas Kellerer
Дата:
Сообщение: Re: Possible to prevent transaction abort?
Следующее
От: David Wall
Дата:
Сообщение: Re: Handling large number of OR/IN conditions