pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: large numbers of inserts out of memory strategy
Date: Mon, 4 Dec 2017 01:01:58 +0100
Message-ID: <20171204000158.e5mngdl4ffvpslhz@hjp.at> (raw)
In-Reply-To: <CAFPpqQEuDCK4s=rBRvoz4V1d1FKaTM5-0UYOQpUGj30oZ6zksg@mail.gmail.com>
References: <87d5d3c9-66e4-c29d-bece-79f2909cccb9@2ndquadrant.com>
	<CAFPpqQGJ9GkntRrjEqvHCRtkbHojmTy93LmCpfuMGJj5F2O7-A@mail.gmail.com>
	<8431416a-2ab2-d580-19bd-2c7e3353960d@2ndquadrant.com>
	<CAAQkdDoq2fXk+E1gtVh_rUuJ99iLGrbc7jWBNkZpGHjytf-3NA@mail.gmail.com>
	<26623.1511927991@sss.pgh.pa.us>
	<CAFPpqQH3BRYg9A5PGGTHh0SQrZEmFegOdPrPSrnJxg19nBB+QA@mail.gmail.com>
	<20171130102209.6q6djwimzzj5opge@hjp.at>
	<CAFPpqQG0D_jsLM8mKH=VgCfC1xkBcv=WA7mEV+4=Eq14iJ88xQ@mail.gmail.com>
	<20171130174005.jc3t5km2f2n4qmk7@hjp.at>
	<CAFPpqQEuDCK4s=rBRvoz4V1d1FKaTM5-0UYOQpUGj30oZ6zksg@mail.gmail.com>

On 2017-11-30 14:27:58 -0600, Ted Toth wrote:
> On Thu, Nov 30, 2017 at 11:40 AM, Peter J. Holzer <hjp-pgsql@hjp.at> wrote:
> > On 2017-11-30 08:43:32 -0600, Ted Toth wrote:
> >> One thing that is unclear to me is when commits occur while using psql
> >> would you know where in the docs I can find information on this
> >> subject?
> >
> > By default psql enables autocommit which causes an implicit commit after
> > every statement. With a do block I'm not sure whether that means after
> > the do block or after each statement within the do block. I'd just turn
> > autocommit off and add explicit commits wherever I wanted them.
> 
> So you think I can turn off autocommit and put BEGIN/COMMITs in a
> large file and then postmaster won't have to parse the whole thing
> when I feed it to it via psql?

No, if you still had one giant do block it would need to parse it
completely. I was thinking of the case where you have many small do
blocks, each with a few insert statements (one do block per "thing"). In
this case it would parse and execute each do block before moving on to
the next. But I wasn't sure whether the default autocommit would mean
one commit after each do block or one commit after each insert statement
(David answered this - thanks), and in any case you probably wouldn't
want to commit after each "thing", so I suggested turning autocommit off
and adding an explicit commit at the end or possibly after every nth
thing.


> > Still: Is there a reason why you use a python script to create an sql
> > script instead of directly issuing the sql queries from your python
> > script?
> 
> I already had code that generated JSON so it was relatively easy to
> add code and a cmd line arg to generate SQL instead.

Ok. that sounds like a good reason.

        hp

-- 
   _  | Peter J. Holzer    | we build much bigger, better disasters now
|_|_) |                    | because we have much more sophisticated
| |   | hjp@hjp.at         | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/;

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (27+ messages)

Message-ID: <20171204000158.e5mngdl4ffvpslhz@hjp.at>
Permalink:  ../20171204000158.e5mngdl4ffvpslhz@hjp.at/
Also on:    postgresql.org/message-id/20171204000158.e5mngdl4ffvpslhz@hjp.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: hjp-pgsql@hjp.at
  Subject: Re: large numbers of inserts out of memory strategy
  In-Reply-To: <20171204000158.e5mngdl4ffvpslhz@hjp.at>
  References: <87d5d3c9-66e4-c29d-bece-79f2909cccb9@2ndquadrant.com> <CAFPpqQGJ9GkntRrjEqvHCRtkbHojmTy93LmCpfuMGJj5F2O7-A@mail.gmail.com> <8431416a-2ab2-d580-19bd-2c7e3353960d@2ndquadrant.com> <CAAQkdDoq2fXk+E1gtVh_rUuJ99iLGrbc7jWBNkZpGHjytf-3NA@mail.gmail.com> <26623.1511927991@sss.pgh.pa.us> <CAFPpqQH3BRYg9A5PGGTHh0SQrZEmFegOdPrPSrnJxg19nBB+QA@mail.gmail.com> <20171130102209.6q6djwimzzj5opge@hjp.at> <CAFPpqQG0D_jsLM8mKH=VgCfC1xkBcv=WA7mEV+4=Eq14iJ88xQ@mail.gmail.com> <20171130174005.jc3t5km2f2n4qmk7@hjp.at> <CAFPpqQEuDCK4s=rBRvoz4V1d1FKaTM5-0UYOQpUGj30oZ6zksg@mail.gmail.com> <20171204000158.e5mngdl4ffvpslhz@hjp.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox