How to pipe the psql copy command to Unix 'Date' command
How to pipe the psql copy command to Unix 'Date' command
От:
SHARMILA JOTHIRAJAH <sharmi_jo@yahoo.com>
Дата:
Hi,
I want to find the time taken by this process ...retrieving data from oracle database using java and copying that to postgres using copy.
So I need something like this
Start_Time|java testCode ...|psql -c "copy dummy from stdin with delimiter ',' null 'NULL'" test| End_time
so that the output is like this
Start_time 2009-02-19 11:30:15
End_time 2009-02-19 11:40:15
This should give me the time this process started and the time it ended. Is that possible?
Thanks
Sharmila
Re: How to pipe the psql copy command to Unix 'Date' command
От:
Mirko Pace <mirkop82@gmail.com>
Дата:
Why not call a function that make an insert as "insert into dummy values ('Start',now())" ?
Mirko
Mirko
On Thu, Feb 19, 2009 at 5:37 PM, SHARMILA JOTHIRAJAH <sharmi_jo@yahoo.com> wrote:
Hi,
I want to find the time taken by this process ...retrieving data from oracle database using java and copying that to postgres using copy.
So I need something like this
Start_Time|java testCode ...|psql -c "copy dummy from stdin with delimiter ',' null 'NULL'" test| End_time
so that the output is like this
Start_time 2009-02-19 11:30:15
End_time 2009-02-19 11:40:15
This should give me the time this process started and the time it ended. Is that possible?
Thanks
Sharmila
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Re: How to pipe the psql copy command to Unix 'Date' command
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
SHARMILA JOTHIRAJAH writes: > Hi, > I want to find the time taken by this process ...retrieving data from oracle database using java and copying that to postgres using copy. > So I need something like this > Start_Time|java testCode ...|psql -c "copy dummy from stdin with delimiter ',' null 'NULL'" test| End_time time java testCode ...|psql -c "copy dummy from stdin with delimiter ',' null 'NULL'" test Or do you really insist on doing the timestamp subtraction by hand? regards, tom lane
Re: How to pipe the psql copy command to Unix 'Date' command
От:
SHARMILA JOTHIRAJAH <sharmi_jo@yahoo.com>
Дата:
--- On Thu, 2/19/09, Tom Lane wrote:
> From: Tom Lane
> Subject: Re: [GENERAL] How to pipe the psql copy command to Unix 'Date' command
> To: sharmi_jo@yahoo.com
> Cc: "General postgres mailing list"
> Date: Thursday, February 19, 2009, 12:31 PM
> SHARMILA JOTHIRAJAH writes:
> > Hi,
> > I want to find the time taken by this process
> ...retrieving data from oracle database using java and
> copying that to postgres using copy.
> > So I need something like this
>
> > Start_Time|java testCode ...|psql -c "copy dummy
> from stdin with delimiter ',' null
> 'NULL'" test| End_time
>
> time java testCode ...|psql -c "copy dummy from stdin
> with delimiter ',' null 'NULL'" test
>
> Or do you really insist on doing the timestamp subtraction
> by hand?
>
>
No...I would definitely prefer to get the time elapsed between the start of the java program and the end of the copy command... Is that possible ? If not at least the start and the end time so tht i can do the calculation myself
Thanks
Sharmila
Re: How to pipe the psql copy command to Unix 'Date' command
От:
Erik Jones <ejones@engineyard.com>
Дата:
On Feb 19, 2009, at 9:40 AM, SHARMILA JOTHIRAJAH wrote: > --- On Thu, 2/19/09, Tom Lane wrote: > >> From: Tom Lane >> Subject: Re: [GENERAL] How to pipe the psql copy command to Unix >> 'Date' command >> To: sharmi_jo@yahoo.com >> Cc: "General postgres mailing list" >> Date: Thursday, February 19, 2009, 12:31 PM >> SHARMILA JOTHIRAJAH writes: >>> Hi, >>> I want to find the time taken by this process >> ...retrieving data from oracle database using java and >> copying that to postgres using copy. >>> So I need something like this >> >>> Start_Time|java testCode ...|psql -c "copy dummy >> from stdin with delimiter ',' null >> 'NULL'" test| End_time >> >> time java testCode ...|psql -c "copy dummy from stdin >> with delimiter ',' null 'NULL'" test >> >> Or do you really insist on doing the timestamp subtraction >> by hand? >> >> > No...I would definitely prefer to get the time elapsed between the > start of the java program and the end of the copy command... Is that > possible ? If not at least the start and the end time so tht i can > do the calculation myself Tom just showed you how. Use run full piped command with the unix 'time' utility. Erik Jones, Database Administrator Engine Yard Support, Scalability, Reliability 866.518.9273 x 260 Location: US/Pacific IRC: mage2k
Re: How to pipe the psql copy command to Unix 'Date' command
От:
SHARMILA JOTHIRAJAH <sharmi_jo@yahoo.com>
Дата:
Thanks all
-Sharmila
--- On Thu, 2/19/09, Erik Jones wrote:
> From: Erik Jones
> Subject: Re: [GENERAL] How to pipe the psql copy command to Unix 'Date' command
> To: sharmi_jo@yahoo.com
> Cc: "Tom Lane" , "General postgres mailing list"
> Date: Thursday, February 19, 2009, 1:31 PM
> On Feb 19, 2009, at 9:40 AM, SHARMILA JOTHIRAJAH wrote:
>
> > --- On Thu, 2/19/09, Tom Lane
> wrote:
> >
> >> From: Tom Lane
> >> Subject: Re: [GENERAL] How to pipe the psql copy
> command to Unix 'Date' command
> >> To: sharmi_jo@yahoo.com
> >> Cc: "General postgres mailing list"
>
> >> Date: Thursday, February 19, 2009, 12:31 PM
> >> SHARMILA JOTHIRAJAH
> writes:
> >>> Hi,
> >>> I want to find the time taken by this process
> >> ...retrieving data from oracle database using java
> and
> >> copying that to postgres using copy.
> >>> So I need something like this
> >>
> >>> Start_Time|java testCode ...|psql -c
> "copy dummy
> >> from stdin with delimiter ',' null
> >> 'NULL'" test| End_time
> >>
> >> time java testCode ...|psql -c "copy dummy
> from stdin
> >> with delimiter ',' null
> 'NULL'" test
> >>
> >> Or do you really insist on doing the timestamp
> subtraction
> >> by hand?
> >>
> >>
> > No...I would definitely prefer to get the time elapsed
> between the start of the java program and the end of the
> copy command... Is that possible ? If not at least the start
> and the end time so tht i can do the calculation myself
>
> Tom just showed you how. Use run full piped command with
> the unix 'time' utility.
>
> Erik Jones, Database Administrator
> Engine Yard
> Support, Scalability, Reliability
> 866.518.9273 x 260
> Location: US/Pacific
> IRC: mage2k
Re: How to pipe the psql copy command to Unix 'Date' command
От:
R Smith <4otherbusiness@comcast.net>
Дата:
On Feb 19, 2009, at 11:07 AM, SHARMILA JOTHIRAJAH wrote: > Thanks all > -Sharmila > > > --- On Thu, 2/19/09, Erik Jones wrote: > >> From: Erik Jones >> Subject: Re: [GENERAL] How to pipe the psql copy command to Unix >> 'Date' command >> To: sharmi_jo@yahoo.com >> Cc: "Tom Lane" , "General postgres mailing list" >> >> Date: Thursday, February 19, 2009, 1:31 PM >> On Feb 19, 2009, at 9:40 AM, SHARMILA JOTHIRAJAH wrote: >> >>> --- On Thu, 2/19/09, Tom Lane >> wrote: >>> >>>> From: Tom Lane >>>> Subject: Re: [GENERAL] How to pipe the psql copy >> command to Unix 'Date' command >>>> To: sharmi_jo@yahoo.com >>>> Cc: "General postgres mailing list" >> >>>> Date: Thursday, February 19, 2009, 12:31 PM >>>> SHARMILA JOTHIRAJAH >> writes: >>>>> Hi, >>>>> I want to find the time taken by this process >>>> ...retrieving data from oracle database using java >> and >>>> copying that to postgres using copy. >>>>> So I need something like this >>>> >>>>> Start_Time|java testCode ...|psql -c >> "copy dummy >>>> from stdin with delimiter ',' null >>>> 'NULL'" test| End_time >>>> >>>> time java testCode ...|psql -c "copy dummy >> from stdin >>>> with delimiter ',' null >> 'NULL'" test >>>> >>>> Or do you really insist on doing the timestamp >> subtraction >>>> by hand? >>>> >>>> >>> No...I would definitely prefer to get the time elapsed >> between the start of the java program and the end of the >> copy command... Is that possible ? If not at least the start >> and the end time so tht i can do the calculation myself >> >> Tom just showed you how. Use run full piped command with >> the unix 'time' utility. >> >> Erik Jones, Database Administrator > I've used UNIX for years and I don't know what you mean by 'use run full piped command'. Sure I know pipes and scripting, but ? I would put everything needed w/ a shell script, calls to java & PG, and set a var to unixtime at start and subtract it from the ending unixtime. If nothing else, I might pick up a Linux trick! Thanks, Ralph Smith
Re: How to pipe the psql copy command to Unix 'Date' command
От:
Erik Jones <ejones@engineyard.com>
Дата:
On Feb 19, 2009, at 6:30 PM, R Smith wrote: > > On Feb 19, 2009, at 11:07 AM, SHARMILA JOTHIRAJAH wrote: > >> Thanks all >> -Sharmila >> >> >> --- On Thu, 2/19/09, Erik Jones wrote: >> >>> From: Erik Jones >>> Subject: Re: [GENERAL] How to pipe the psql copy command to Unix >>> 'Date' command >>> To: sharmi_jo@yahoo.com >>> Cc: "Tom Lane" , "General postgres mailing >>> list" >>> Date: Thursday, February 19, 2009, 1:31 PM >>> On Feb 19, 2009, at 9:40 AM, SHARMILA JOTHIRAJAH wrote: >>> >>>> --- On Thu, 2/19/09, Tom Lane >>> wrote: >>>> >>>>> From: Tom Lane >>>>> Subject: Re: [GENERAL] How to pipe the psql copy >>> command to Unix 'Date' command >>>>> To: sharmi_jo@yahoo.com >>>>> Cc: "General postgres mailing list" >>> >>>>> Date: Thursday, February 19, 2009, 12:31 PM >>>>> SHARMILA JOTHIRAJAH >>> writes: >>>>>> Hi, >>>>>> I want to find the time taken by this process >>>>> ...retrieving data from oracle database using java >>> and >>>>> copying that to postgres using copy. >>>>>> So I need something like this >>>>> >>>>>> Start_Time|java testCode ...|psql -c >>> "copy dummy >>>>> from stdin with delimiter ',' null >>>>> 'NULL'" test| End_time >>>>> >>>>> time java testCode ...|psql -c "copy dummy >>> from stdin >>>>> with delimiter ',' null >>> 'NULL'" test >>>>> >>>>> Or do you really insist on doing the timestamp >>> subtraction >>>>> by hand? >>>>> >>>>> >>>> No...I would definitely prefer to get the time elapsed >>> between the start of the java program and the end of the >>> copy command... Is that possible ? If not at least the start >>> and the end time so tht i can do the calculation myself >>> >>> Tom just showed you how. Use run full piped command with >>> the unix 'time' utility. >>> >>> Erik Jones, Database Administrator >> > I've used UNIX for years and I don't know what you mean by 'use run > full piped command'. > Sure I know pipes and scripting, but ? > I would put everything needed w/ a shell script, calls to java & PG, > and set a var to unixtime at start and subtract it from the ending > unixtime. > > If nothing else, I might pick up a Linux trick! Sorry, I'd started typing the sentence one say, back spaced and went to type it another and it didn't really come out right. It should have been: Run the full piped command with the unix 'time' utility. I.e. if the full piped command was: cmd1 someargs | cmd2 someargs2 | cmd3 someargs3 then run: time cmd1 someargs | cmd2 someargs2 | cmd3 someargs3 Erik Jones, Database Administrator Engine Yard Support, Scalability, Reliability 866.518.9273 x 260 Location: US/Pacific IRC: mage2k
Re: How to pipe the psql copy command to Unix 'Date' command
От:
SHARMILA JOTHIRAJAH <sharmi_jo@yahoo.com>
Дата:
--- On Thu, 2/19/09, Erik Jones wrote:
> From: Erik Jones
> Subject: Re: [GENERAL] How to pipe the psql copy command to Unix 'Date' command
> To: "R Smith" <4otherbusiness@comcast.net>
> Cc: "General postgres mailing list"
> Date: Thursday, February 19, 2009, 11:08 PM
> On Feb 19, 2009, at 6:30 PM, R Smith wrote:
>
> >
> > On Feb 19, 2009, at 11:07 AM, SHARMILA JOTHIRAJAH
> wrote:
> >
> >> Thanks all
> >> -Sharmila
> >>
> >>
> >> --- On Thu, 2/19/09, Erik Jones
> wrote:
> >>
> >>> From: Erik Jones
> >>> Subject: Re: [GENERAL] How to pipe the psql
> copy command to Unix 'Date' command
> >>> To: sharmi_jo@yahoo.com
> >>> Cc: "Tom Lane"
> , "General postgres mailing
> list"
> >>> Date: Thursday, February 19, 2009, 1:31 PM
> >>> On Feb 19, 2009, at 9:40 AM, SHARMILA
> JOTHIRAJAH wrote:
> >>>
> >>>> --- On Thu, 2/19/09, Tom Lane
> >>> wrote:
> >>>>
> >>>>> From: Tom Lane
>
> >>>>> Subject: Re: [GENERAL] How to pipe the
> psql copy
> >>> command to Unix 'Date' command
> >>>>> To: sharmi_jo@yahoo.com
> >>>>> Cc: "General postgres mailing
> list"
> >>>
> >>>>> Date: Thursday, February 19, 2009,
> 12:31 PM
> >>>>> SHARMILA JOTHIRAJAH
>
> >>> writes:
> >>>>>> Hi,
> >>>>>> I want to find the time taken by
> this process
> >>>>> ...retrieving data from oracle
> database using java
> >>> and
> >>>>> copying that to postgres using copy.
> >>>>>> So I need something like this
> >>>>>
> >>>>>> Start_Time|java testCode ...|psql
> -c
> >>> "copy dummy
> >>>>> from stdin with delimiter ','
> null
> >>>>> 'NULL'" test| End_time
> >>>>>
> >>>>> time java testCode ...|psql -c
> "copy dummy
> >>> from stdin
> >>>>> with delimiter ',' null
> >>> 'NULL'" test
> >>>>>
> >>>>> Or do you really insist on doing the
> timestamp
> >>> subtraction
> >>>>> by hand?
> >>>>>
> >>>>>
> >>>> No...I would definitely prefer to get the
> time elapsed
> >>> between the start of the java program and the
> end of the
> >>> copy command... Is that possible ? If not at
> least the start
> >>> and the end time so tht i can do the
> calculation myself
> >>>
> >>> Tom just showed you how. Use run full piped
> command with
> >>> the unix 'time' utility.
> >>>
> >>> Erik Jones, Database Administrator
> >>
> > I've used UNIX for years and I don't know what
> you mean by 'use run full piped command'.
> > Sure I know pipes and scripting, but ?
> > I would put everything needed w/ a shell script, calls
> to java & PG, and set a var to unixtime at start and
> subtract it from the ending unixtime.
> >
> > If nothing else, I might pick up a Linux trick!
>
> Sorry, I'd started typing the sentence one say, back
> spaced and went to type it another and it didn't really
> come out right. It should have been:
>
> Run the full piped command with the unix 'time'
> utility.
>
> I.e. if the full piped command was: cmd1 someargs | cmd2
> someargs2 | cmd3 someargs3
>
> then run: time cmd1 someargs | cmd2 someargs2 | cmd3
> someargs3
Is it possible to sent this 'time' output to a file...
If I try
time cmd1 someargs1 | cmd2 someargs2 > output.log
it doesn't sent the "time" to the file...
Why?
Thanks
Sharmila
Re: How to pipe the psql copy command to Unix 'Date' command
От:
John R Pierce <pierce@hogranch.com>
Дата:
SHARMILA JOTHIRAJAH wrote: > Is it possible to sent this 'time' output to a file... > If I try > time cmd1 someargs1 | cmd2 someargs2 > output.log > > it doesn't sent the "time" to the file... > time (cmd1 someargs1 | cmd2 someargs2) > output.log the way you had it, it was only timing cmd1. with the ( ), its spawning a subshell which should run both commands piped...
Re: How to pipe the psql copy command to Unix 'Date' command
От:
Alan Hodgson <ahodgson@simkin.ca>
Дата:
On Monday 02 March 2009, John R Pierce wrote: > SHARMILA JOTHIRAJAH wrote: > > Is it possible to sent this 'time' output to a file... > > If I try > > time cmd1 someargs1 | cmd2 someargs2 > output.log > > > > it doesn't sent the "time" to the file... > > time (cmd1 someargs1 | cmd2 someargs2) > output.log > > > the way you had it, it was only timing cmd1. with the ( ), its spawning > a subshell which should run both commands piped... time also reports on stderr, not stdout. time (cmd1 someargs1 | cmd2 someargs2) > output.log 2>&1 -- Even a sixth-grader can figure out that you can’t borrow money to pay off your debt