Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T92e3-00043S-Dv for pgsql-performance@postgresql.org; Tue, 04 Sep 2012 23:34:59 +0000 Received: from nm34-vm5.bullet.mail.sg3.yahoo.com ([106.10.151.244]) by magus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1T92dz-00044n-3S for pgsql-performance@postgresql.org; Tue, 04 Sep 2012 23:34:58 +0000 Received: from [106.10.166.117] by nm34.bullet.mail.sg3.yahoo.com with NNFMP; 04 Sep 2012 23:34:51 -0000 Received: from [106.10.150.27] by tm6.bullet.mail.sg3.yahoo.com with NNFMP; 04 Sep 2012 23:34:51 -0000 Received: from [127.0.0.1] by omp1028.mail.sg3.yahoo.com with NNFMP; 04 Sep 2012 23:34:51 -0000 X-Yahoo-Newman-Id: 841958.3914.bm@omp1028.mail.sg3.yahoo.com Received: (qmail 87994 invoked from network); 4 Sep 2012 23:34:51 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=DKIM-Signature:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:References:In-Reply-To:Mime-Version:Content-Type:Received:Message-Id:Content-Transfer-Encoding:Cc:X-Mailer:X-Ymail-Umid:From:Subject:Date:To; b=2fduDfH1qMdel1XLuAbleduxGAwKf2S0haJClo9ToBWc+5CWUmx4nK6jNZNLy0BSZckBTjxaKEr+hRyasJytDuK9l55zwhmbDo3EZ/QqT498BX2AyXrDFFPSaMBmeCkr5XuG+XUNn02XxV3lQDpFZTEvSQ3hHZzgHiQvyTY+bz8= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1346801691; bh=1n/C7f1qYvpknrpExs9wBLf/Fj8uJY/xOg0yOywTB5A=; h=X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:References:In-Reply-To:Mime-Version:Content-Type:Received:Message-Id:Content-Transf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ljVj3tQl1ll 9nd6nINXb5sVvkOL4yodiYZxSeujRM9CTEk3zpC_UDt3ZNvI8kgz9dslj9xe SMf_VPGeciHvOSvPvsZIKoJjXpocz9k8YHQWLfu4lRBgD2NSyvHDwiG3xU8A PIPb.PGmqx.0_RPcc_KT0MCsR2pFuBMuzH2AmTKTsiS6_wa_2XUI7jg8N5k2 LMWodJvMPIxdyunWy4h2jTwgH.IZ1EuHhw5nXEica9E1cd33BhtHXAf5WBrd Ss.Q6qgf6FRm8Y5KK44IvsVibmO9MGFFTx1dC2n4wyVza5d6PMq_jAMnHfcO E0fikQ_zW4coZfdVNrAo2TU44hD_sB4huVZAg6a6A37OV82RequDT60THxVn M2pgY14GDOtAAUqSa6Ag8iWd1igr7hEHK4eAdKhbphhCcMdfcqJZLg4Pxeqo uFh3QnLTD_uC.kNd9vMQSpL7opXkjay6wjUqOD51xgBgFWuMDnS1RAArbKBx DWqLFu426.cEaya92idoEIHA.jBjuqoChRHtATPvGeP3K0olKiQg6LZTPOoC 9rvfZUHTOPMFffets2RbYLS7Mvkf3uzh_PIDtBBhymcV8esYlVU6bbPQ1qNq uNq6D46Ce7FaKSSBZ X-Yahoo-SMTP: DLUwYlSswBC0ZdDmQ1ARmGbonv.K Received: from [192.168.11.5] (hey_here@114.42.17.28 with xymcookie) by smtp121-mob.biz.mail.sg3.yahoo.com with SMTP; 04 Sep 2012 23:34:49 +0000 UTC References: <1346308496.83000.YahooMailNeo@web141101.mail.bf1.yahoo.com> In-Reply-To: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=Apple-Mail-1--872706810 Received: from [68.5.79.97] by web141103.mail.bf1.yahoo.com via HTTP; Tue, 04 Sep 2012 02:32:44 PDT Message-Id: <6DD46001-B666-4D55-8B4E-F38D96CE0FE4@yahoo.com> Content-Transfer-Encoding: 7bit Cc: "pgsql-performance@postgresql.org" X-Mailer: iPhone Mail (8E200) X-Ymail-Umid: 2_0_0_3_2487_AJLtHkgAAI2jUEXKvA70M3ja79Q From: Eileen Subject: Re: JDBC 5 million function insert returning Single Transaction Lock Access Exclusive Problem Date: Tue, 4 Sep 2012 16:34:38 -0700 To: Dave Cramer X-Pg-Spam-Score: -2.2 (--) X-Archive-Number: 201209/16 X-Sequence-Number: 47762 --Apple-Mail-1--872706810 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Thank you for your help. At a high-level, I am just updating about 900k rec= ords in the database with new information, and during that update timetable,= I didn't want users to get inconsistent data. I read about the MVCC and discovered that I didn't necessarily need the LOCK= statement. However, based on what I read, I thought that versions of the d= atabase would include changes to the schema. I found that not to be the cas= e. I.e. when I queried the database while a transaction was in the process o= f DROPing tables, it gave me an error instead of an older snapshot. Is ther= e any database which actually isolates schema changes? I was just curious. I have verified that while I'm DELETING rows from one session, that other se= ssions can retrieve the old data in a consistent state. Although, in order t= o actually successfully DELETE the items, I had to add an index for all my Fo= reign Key fields. Tina From: Dave Cramer To: Eileen =20 Cc: "pgsql-performance@postgresql.org" =20= Sent: Friday, August 31, 2012 6:50 AM Subject: Re: [PERFORM] JDBC 5 million function insert returning Single Trans= action Lock Access Exclusive Problem Dave Cramer dave.cramer(at)credativ(dot)ca http://www.credativ.ca On Thu, Aug 30, 2012 at 2:34 AM, Eileen wrote: > Hi, > > I have written some Java code which builds a postgresql function. That > function calls approximately 6 INSERT statements with a RETURNING clause. = I > recreate and re-run the function about 900,000 times. I use JDBC to execu= te > these functions on postgresql 8.3 on Windows. When I tried running this o= n > a single Connection of Postgresql, it failed (some kind of memory error). > So I split the JDBC connections up into chunks of 5000. I reran and > everything was fine. It took about 1 hour to execute all the updates. > > Since it took so long to perform the update, I wanted to prevent other use= rs > from querying the data during that time. So I read about the LOCK command= . > It seemed like I should LOCK all the tables in the database with an ACCESS= > EXCLUSIVE mode. That would prevent anyone from getting data while the > database was making its updates. Do you understand how MVCC works? Do you really need to lock out users ? > > Since a LOCK is only valid for 1 transaction, I set autocommit to FALSE. I= > also removed the code which chunked up the inserts. I had read that a > single transaction ought to have better performance than committing after > each insert, but that was clearly not what ended up happening in my case. We would need more information as to what you are doing. > > In my case, a few problems occurred. Number 1, the process ran at least 8= > hours and never finished. It did not finish because the hard drive was > filled up. After running a manual vacuum (VACUUM FULL), no space was free= d > up. I think this has cost me 20 GB of space. Is there any way to free th= is > space up? I even dropped the database to no avail. > > Secondly, why did this process take over 8 hours to run? While reading th= e > performance mailing list, it seems like recommendations are to run lots of= > INSERTS in a single commit. Is 5 million too many? Is redefining a > function over and over inside a transaction a problem? Does the RETURNING= > clause present a problem during a single transaction? VACUUM FULL on 8.3 is not a good idea > > If anyone has any suggestions for me, I would really appreciate it. > Can you explain at a high level what you are trying to do ? > Tina --=20 Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance =20 --Apple-Mail-1--872706810 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
Thank you for your help.  At = a high-level, I am just updating about 900k records in the database with = new information, and during that update timetable, I didn't want users to = get inconsistent data.

I read about the MVCC and discovered that I didn't necessarily need the LOCK statement.  = However, based on what I read, I thought that versions of the database = would include changes to the schema.  I found that not to be the = case.  I.e. when I queried the database while a transaction was in = the process of DROPing tables, it gave me an error instead of an older = snapshot.  Is there any database which actually isolates schema = changes?  I was just curious.

I have verified that while I'm DELETING rows from one session, that other sessions can retrieve the = old data in a consistent state.  Although, in order to actually = successfully DELETE the items, I had to add an index for all my Foreign = Key fields.

Tina


From: Dave Cramer <pg=40fastcrypt.com>
To: Eileen <hey_here=40yahoo.com> =
Cc: =22pgsql-performance=40= postgresql.org=22 <pgsql-performance=40= postgresql.org>
Sent: Friday, August 31, 2012 6:50 AM
Subject: Re: =5BPERFORM=5D JDBC 5 million function = insert returning Single Transaction Lock Access Exclusive Problem
=

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca

<= br>On Thu, Aug 30, 2012 at 2:34 AM, Eileen <hey_here=40yahoo.com> = wrote:
> Hi,
>
> I have written some Java code which = builds a postgresql function.  That
> function calls = approximately 6 INSERT statements with a RETURNING clause.  I
> = recreate and re-run the function about 900,000 times.  I use JDBC to = execute
> these functions on postgresql 8.3 on Windows.  When I = tried running this on
> a single Connection of Postgresql, it failed = (some kind of memory error).
> So I split the JDBC connections up = into chunks of 5000.  I reran and
> everything was fine.  = It took about 1 hour to execute all the updates.


>
> = Since it took so long to perform the update, I wanted to prevent other users
> from querying the = data during that time.  So I read about the LOCK command.
> It = seemed like I should LOCK all the tables in the database with an = ACCESS
> EXCLUSIVE mode.  That would prevent anyone from = getting data while the
> database was making its updates.

Do = you understand how MVCC works? Do you really need to lock out users = ?
>
> Since a LOCK is only valid for 1 transaction, I set = autocommit to FALSE.  I
> also removed the code which chunked = up the inserts.  I had read that a
> single transaction ought = to have better performance than committing after
> each insert, but = that was clearly not what ended up happening in my case.

We would = need more information as to what you are doing.
>
> In my = case, a few problems occurred.  Number 1, the process ran at least = 8
> hours and never finished.  It did not finish because the hard drive was
> filled up.  = After running a manual vacuum (VACUUM FULL), no space was freed
> = up.  I think this has cost me 20 GB of space.  Is there any way = to free this
> space up?  I even dropped the database to no = avail.
>
> Secondly, why did this process take over 8 hours to = run?  While reading the
> performance mailing list, it seems = like recommendations are to run lots of
> INSERTS in a single = commit.  Is 5 million too many?  Is redefining a
> = function over and over inside a transaction a problem?  Does the = RETURNING
> clause present a problem during a single = transaction?

VACUUM FULL on 8.3 is not a good idea
>
> = If anyone has any suggestions for me, I would really appreciate = it.
>

Can you explain at a high level what you are trying to = do ?

> Tina


--
Sent via pgsql-performance mailing list (pgsql-performance=40= postgresql.org)
To make changes to your subscription:
http://ww= w.postgresql.org/mailpref/pgsql-performance


=
= --Apple-Mail-1--872706810--