Re: Is there a way to tell how far along a COPY is in the process?
От | andy |
---|---|
Тема | Re: Is there a way to tell how far along a COPY is in the process? |
Дата | |
Msg-id | 472F7868.8000401@squeakycode.net обсуждение исходный текст |
Ответ на | Is there a way to tell how far along a COPY is in the process? (Keaton Adams <kadams@mxlogic.com>) |
Список | 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
В списке pgsql-general по дате отправления: