From: | andy <andy(at)squeakycode(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Is there a way to tell how far along a COPY is in the process? |
Date: | 2007-11-05 20:09:12 |
Message-ID: | 472F7868.8000401@squeakycode.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Keaton Adams wrote:
>
> I’m looking for a way to see how many rows have been processed while a
> COPY is actually running. I can’t seem to find a pg_stat table/view
> that will give me this level of visibility into the process.
>
> Is there any way to do this, to tell the number of rows processed during
> a COPY into a table while the COPY is still running?
>
> Thanks,
>
> Keaton
I use this little perl function:
sub runscript($)
{
my $fname = pop;
open(F, $fname) or die;
print "executing $fname\n";
my $sql = <F>;
$db->do($sql) or die 'cant start copy';
my $c = 0;
while (<F>)
{
$db->pg_putline($_);
if ($c % 10_000 == 0) {
print "$c\r";
if ($stop) { die; }
}
$c++;
}
print "$c total\n";
$db->pg_endcopy;
unlink($fname);
}
The first line in the file needs to be the sql copy command, like:
print F "copy junk(id, name, address) from stdin;\n";
The following lines are the data, like:
print F "$id\t$name\t$add\n";
-Andy
From | Date | Subject | |
---|---|---|---|
Next Message | Reg Me Please | 2007-11-05 20:27:27 | Locale and indexes: howto? |
Previous Message | Tom Lane | 2007-11-05 20:07:03 | Re: Filter sequence |