mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
Fix progress logging when scale factor is large.
Integer overflow showed minus percent and minus remaining time something like this. 239300000 of 3800000000 tuples (-48%) done (elapsed 226.86 s, remaining -696.10 s).
This commit is contained in:
parent
6dc71a7e77
commit
27902bc916
@ -1610,11 +1610,11 @@ init(bool is_no_vacuum)
|
|||||||
INSTR_TIME_SUBTRACT(diff, start);
|
INSTR_TIME_SUBTRACT(diff, start);
|
||||||
|
|
||||||
elapsed_sec = INSTR_TIME_GET_DOUBLE(diff);
|
elapsed_sec = INSTR_TIME_GET_DOUBLE(diff);
|
||||||
remaining_sec = (scale * naccounts - j) * elapsed_sec / j;
|
remaining_sec = ((double) scale * naccounts - j) * elapsed_sec / j;
|
||||||
|
|
||||||
fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) done (elapsed %.2f s, remaining %.2f s).\n",
|
fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) done (elapsed %.2f s, remaining %.2f s).\n",
|
||||||
j, (int64) naccounts * scale,
|
j, (int64) naccounts * scale,
|
||||||
(int) (((int64) j * 100) / (naccounts * scale)),
|
(int) (((int64) j * 100) / (naccounts * (int64) scale)),
|
||||||
elapsed_sec, remaining_sec);
|
elapsed_sec, remaining_sec);
|
||||||
}
|
}
|
||||||
/* let's not call the timing for each row, but only each 100 rows */
|
/* let's not call the timing for each row, but only each 100 rows */
|
||||||
@ -1624,14 +1624,14 @@ init(bool is_no_vacuum)
|
|||||||
INSTR_TIME_SUBTRACT(diff, start);
|
INSTR_TIME_SUBTRACT(diff, start);
|
||||||
|
|
||||||
elapsed_sec = INSTR_TIME_GET_DOUBLE(diff);
|
elapsed_sec = INSTR_TIME_GET_DOUBLE(diff);
|
||||||
remaining_sec = (scale * naccounts - j) * elapsed_sec / j;
|
remaining_sec = ((double) scale * naccounts - j) * elapsed_sec / j;
|
||||||
|
|
||||||
/* have we reached the next interval (or end)? */
|
/* have we reached the next interval (or end)? */
|
||||||
if ((j == scale * naccounts) || (elapsed_sec >= log_interval * LOG_STEP_SECONDS))
|
if ((j == scale * naccounts) || (elapsed_sec >= log_interval * LOG_STEP_SECONDS))
|
||||||
{
|
{
|
||||||
fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) done (elapsed %.2f s, remaining %.2f s).\n",
|
fprintf(stderr, INT64_FORMAT " of " INT64_FORMAT " tuples (%d%%) done (elapsed %.2f s, remaining %.2f s).\n",
|
||||||
j, (int64) naccounts * scale,
|
j, (int64) naccounts * scale,
|
||||||
(int) (((int64) j * 100) / (naccounts * scale)), elapsed_sec, remaining_sec);
|
(int) (((int64) j * 100) / (naccounts * (int64) scale)), elapsed_sec, remaining_sec);
|
||||||
|
|
||||||
/* skip to the next interval */
|
/* skip to the next interval */
|
||||||
log_interval = (int) ceil(elapsed_sec / LOG_STEP_SECONDS);
|
log_interval = (int) ceil(elapsed_sec / LOG_STEP_SECONDS);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user