How to use postgres 7.0.3 with -F?

Started by Konstantinos Agourosabout 25 years ago5 messagesgeneral
Jump to latest
#1Konstantinos Agouros
elwood@agouros.de

Hi,

someone gave me the tip to use the -F-flag to improve performance. Since
I can't run the postmaster with -F but just postgres how do I do it, if I
want to import a big amount of data?

Konstantin
--
Dipl-Inf. Konstantin Agouros aka Elwood Blues. Internet: elwood@agouros.de
Otkerstr. 28, 81547 Muenchen, Germany. Tel +49 89 69370185
----------------------------------------------------------------------------
"Captain, this ship will not sustain the forming of the cosmos." B'Elana Torres

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Konstantinos Agouros (#1)
Re: How to use postgres 7.0.3 with -F?

elwood@agouros.de (Konstantinos Agouros) writes:

someone gave me the tip to use the -F-flag to improve performance. Since
I can't run the postmaster with -F but just postgres how do I do it, if I
want to import a big amount of data?

In 7.0.* (but not prior versions) it is safe to run individual backends
with -F; other backends will still fsync their changes. So, you can
start a backend that's going to do an import with

export PGOPTIONS="-F"
psql mydb
....

(adjust 'export' command syntax depending on your preferred shell.)
libpq passes the value of the environment variable PGOPTIONS over to the
backend, and away you go. -dN (debug level) is another backend command-
line switch commonly set this way.

regards, tom lane

#3Konstantinos Agouros
elwood@agouros.de
In reply to: Konstantinos Agouros (#1)
Re: How to use postgres 7.0.3 with -F?

In <12492.982346115@sss.pgh.pa.us> tgl@sss.pgh.pa.us (Tom Lane) writes:

elwood@agouros.de (Konstantinos Agouros) writes:

someone gave me the tip to use the -F-flag to improve performance. Since
I can't run the postmaster with -F but just postgres how do I do it, if I
want to import a big amount of data?

In 7.0.* (but not prior versions) it is safe to run individual backends
with -F; other backends will still fsync their changes. So, you can
start a backend that's going to do an import with

export PGOPTIONS="-F"
psql mydb
....

(adjust 'export' command syntax depending on your preferred shell.)
libpq passes the value of the environment variable PGOPTIONS over to the
backend, and away you go. -dN (debug level) is another backend command-
line switch commonly set this way.

Ahhhh Ohhhh thanks for the help I was confused. Does this also work that way, if
I use it from DBI::Pg from perl? Like setting $ENV{'PGOPTIONS'}

Konstantin

regards, tom lane

--
Dipl-Inf. Konstantin Agouros aka Elwood Blues. Internet: elwood@agouros.de
Otkerstr. 28, 81547 Muenchen, Germany. Tel +49 89 69370185
----------------------------------------------------------------------------
"Captain, this ship will not sustain the forming of the cosmos." B'Elana Torres

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Konstantinos Agouros (#3)
Re: How to use postgres 7.0.3 with -F?

elwood@agouros.de (Konstantinos Agouros) writes:

export PGOPTIONS="-F"
psql mydb

Ahhhh Ohhhh thanks for the help I was confused. Does this also work
that way, if I use it from DBI::Pg from perl? Like setting
$ENV{'PGOPTIONS'}

Yeah, I think that should work if you do it before opening a connection,
but a more straightforward way is to set options=-F in the
DBI->connect() command ...

regards, tom lane

#5Doug McNaught
doug@wireboard.com
In reply to: Konstantinos Agouros (#1)
Re: How to use postgres 7.0.3 with -F?

Tom Lane <tgl@sss.pgh.pa.us> writes:

elwood@agouros.de (Konstantinos Agouros) writes:

export PGOPTIONS="-F"
psql mydb

Ahhhh Ohhhh thanks for the help I was confused. Does this also work
that way, if I use it from DBI::Pg from perl? Like setting
$ENV{'PGOPTIONS'}

Yeah, I think that should work if you do it before opening a connection,
but a more straightforward way is to set options=-F in the
DBI->connect() command ...

I think Tom's suggestion is the way to go--I found a long time ago
that Perl only puts the %ENV hash into the environment when it's about
to call exec(). I was using DBD::Informix and found that my
INFORMIXDIR variable, set in the Perl script, was not making it
through to the Informix libraries (since no separate program was being
called). I had to run the Perl script from a wrapper shell script
that set INFORMIXDIR...

This may have been fixed by now, though, it was five years ago or so.

-Doug