pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #15008: Need a pause
3+ messages / 3 participants
[nested] [flat]

* BUG #15008: Need a pause
@ 2018-01-12 09:26 PG Bug reporting form <noreply@postgresql.org>
  2018-01-12 09:39 ` RE: BUG #15008: Need a pause Greg Clough <greg.clough@ipreo.com>
  0 siblings, 1 reply; 3+ messages in thread

From: PG Bug reporting form @ 2018-01-12 09:26 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: martellilaurent@gmail.com

The following bug has been logged on the website:

Bug reference:      15008
Logged by:          Laurent Martelli
Email address:      martellilaurent@gmail.com
PostgreSQL version: 9.6.6
Operating system:   Debian 9.3
Description:        

I have a set of scripts I execute with psql, and for some reason, a query in
one of them take forever (never had the patience to wait for more than 15
minutes), eating 1 CPU, unless I insert a pause (sleep 60) before that
script, and then it only takes a few seconds.

It only occurs when the tables we operate on have a sufficient number of
rows. When we do "unit" tests with a subset of the data, it all goes
smoothly.

Please, tell me what additional information I can provide to help fix this.



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* RE: BUG #15008: Need a pause
  2018-01-12 09:26 BUG #15008: Need a pause PG Bug reporting form <noreply@postgresql.org>
@ 2018-01-12 09:39 ` Greg Clough <greg.clough@ipreo.com>
  2018-01-12 13:12   ` Re: BUG #15008: Need a pause Laurent Martelli <martellilaurent@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Greg Clough @ 2018-01-12 09:39 UTC (permalink / raw)
  To: martellilaurent@gmail.com <martellilaurent@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

> The following bug has been logged on the website:
> 
> Bug reference:      15008
> Logged by:          Laurent Martelli
> Email address:      martellilaurent@gmail.com
> PostgreSQL version: 9.6.6
> Operating system:   Debian 9.3
> Description:        
>
> I have a set of scripts I execute with psql, and for some reason, a query in one of them take forever (never had the patience to wait for more than 15 minutes), eating 1 CPU, unless I insert a pause (sleep 60) before that script, and then it only takes a few seconds.
>
> It only occurs when the tables we operate on have a sufficient number of rows. When we do "unit" tests with a subset of the data, it all goes smoothly.
>
> Please, tell me what additional information I can provide to help fix this.

It sounds like you're bulk-loading rows, and not updating the table statistics before running a query.  The pause may give autovacuum time to find and analyze the table so you get the correct query plan.  I'd suggest you modify your script to add EXPLAIN ANALYZE to your query and then run it with and without the pause.  Probably you'll find one is doing a full table scan, and the other is using an index.

More than likely you will need to add an "ANALYZE table_name;" into your script in place of the pause

Greg Clough
Senior Technology Engineer
O  | +44 (0) 20 7665 9787
M | +44 (0) 7803 142 292

Ipreo
Castle House | 37-35 Paul St | London EC2A 4LS


^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #15008: Need a pause
  2018-01-12 09:26 BUG #15008: Need a pause PG Bug reporting form <noreply@postgresql.org>
  2018-01-12 09:39 ` RE: BUG #15008: Need a pause Greg Clough <greg.clough@ipreo.com>
@ 2018-01-12 13:12   ` Laurent Martelli <martellilaurent@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Laurent Martelli @ 2018-01-12 13:12 UTC (permalink / raw)
  To: Greg Clough <greg.clough@ipreo.com>; +Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

You are absolutely right !

Sorry for the noise here. Next time, I'll post on the user ML first.

Cheers,
Laurent

2018-01-12 10:39 GMT+01:00 Greg Clough <greg.clough@ipreo.com>:

> > The following bug has been logged on the website:
> >
> > Bug reference:      15008
> > Logged by:          Laurent Martelli
> > Email address:      martellilaurent@gmail.com
> > PostgreSQL version: 9.6.6
> > Operating system:   Debian 9.3
> > Description:
> >
> > I have a set of scripts I execute with psql, and for some reason, a
> query in one of them take forever (never had the patience to wait for more
> than 15 minutes), eating 1 CPU, unless I insert a pause (sleep 60) before
> that script, and then it only takes a few seconds.
> >
> > It only occurs when the tables we operate on have a sufficient number of
> rows. When we do "unit" tests with a subset of the data, it all goes
> smoothly.
> >
> > Please, tell me what additional information I can provide to help fix
> this.
>
> It sounds like you're bulk-loading rows, and not updating the table
> statistics before running a query.  The pause may give autovacuum time to
> find and analyze the table so you get the correct query plan.  I'd suggest
> you modify your script to add EXPLAIN ANALYZE to your query and then run it
> with and without the pause.  Probably you'll find one is doing a full table
> scan, and the other is using an index.
>
> More than likely you will need to add an "ANALYZE table_name;" into your
> script in place of the pause
>
> Greg Clough
> Senior Technology Engineer
> O  | +44 (0) 20 7665 9787
> M | +44 (0) 7803 142 292
>
> Ipreo
> Castle House | 37-35 Paul St | London EC2A 4LS
>



-- 
http://www.laurentmartelli.com    //    http://www.imprimart.fr

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2018-01-12 13:12 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-01-12 09:26 BUG #15008: Need a pause PG Bug reporting form <noreply@postgresql.org>
2018-01-12 09:39 ` Greg Clough <greg.clough@ipreo.com>
2018-01-12 13:12   ` Laurent Martelli <martellilaurent@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox