main
Bel LaPointe 2025-12-08 16:35:16 -07:00
parent 8b748280a9
commit 67879cf7b0
1 changed files with 7 additions and 19 deletions

View File

@ -57,25 +57,13 @@ func run(ctx context.Context) error {
// https://gist.github.com/ololobus/5b25c432f208d7eb31051a5f238dffff
// 2e6=1GB, so 2e6/8=12MB
for {
if presently() >= *n {
break
}
for ctx.Err() == nil {
if _, err := pg.ExecContext(ctx, `
INSERT INTO fill_with_data (x, y, z)
SELECT ROUND(RANDOM()), RANDOM(), RANDOM()
FROM generate_series(1, 2e6/8)
`); err != nil {
return fmt.Errorf("failed lo_from_bytea: %w", err)
} else {
break
}
select {
case <-ctx.Done():
return ctx.Err()
default:
}
for ctx.Err() == nil && presently() < *n {
if _, err := pg.ExecContext(ctx, `
INSERT INTO fill_with_data (x, y, z)
SELECT ROUND(RANDOM()), RANDOM(), RANDOM()
FROM generate_series(1, 2e6/8)
`); err != nil {
return fmt.Errorf("failed lo_from_bytea: %w", err)
}
}