pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: slow to run query 5000 times
3+ messages / 3 participants
[nested] [flat]

* Re: slow to run query 5000 times
@ 2019-02-09 17:16 Justin Pryzby <pryzby@telsasoft.com>
  2019-02-09 20:23 ` Re: slow to run query 5000 times Andres Freund <andres@anarazel.de>
  0 siblings, 1 reply; 3+ messages in thread

From: Justin Pryzby @ 2019-02-09 17:16 UTC (permalink / raw)
  To: Evandro Abreu <evandro.abreu@gmail.com>; +Cc: pgsql-performance@lists.postgresql.org

Hi,

Please don't send images to the list, you can send a link to one of the image
host websites if you need to describe something graphical.

But here, you could just send the queries and \d for the tables.

On Sat, Feb 09, 2019 at 01:45:50PM -0300, Evandro Abreu wrote:
> I have a report that takes about 20 minutes to generate. It is generated
> from 3 tables: according to image.
> The report input parameter is a date range. So to generate it I select all
> records in Table A and run them
> in loop-for. For each record in Table A I make a query Table B join with
> Table C where I filter the records through the date field and make the sum
> of the value field.

So you're running query 5000 times ?

Do you really need a for loop ?  Could you just join the 3 tables together and GROUP BY a.id ?

Please send "explain analyze" for the queries, or a link to the output on
depesz site.
https://wiki.postgresql.org/wiki/Slow_Query_Questions#Information_You_Need_To_Include

Also, are they all taking about the same amount of time ?

Justin




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

* Re: slow to run query 5000 times
  2019-02-09 17:16 Re: slow to run query 5000 times Justin Pryzby <pryzby@telsasoft.com>
@ 2019-02-09 20:23 ` Andres Freund <andres@anarazel.de>
  2019-02-10 00:23   ` Re: slow to run query 5000 times Ricardo Martin Gomez <rimartingomez@hotmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Andres Freund @ 2019-02-09 20:23 UTC (permalink / raw)
  To: Justin Pryzby <pryzby@telsasoft.com>; +Cc: Evandro Abreu <evandro.abreu@gmail.com>; pgsql-performance@lists.postgresql.org

Hi,

On 2019-02-09 11:16:33 -0600, Justin Pryzby wrote:
> Please don't send images to the list, you can send a link to one of the image
> host websites if you need to describe something graphical.

FWIW, I don't agree with that policy. I plenty of time process email
while withoug internet, so I appreciate self contained email.

Greetings,

Andres Freund




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

* Re: slow to run query 5000 times
  2019-02-09 17:16 Re: slow to run query 5000 times Justin Pryzby <pryzby@telsasoft.com>
  2019-02-09 20:23 ` Re: slow to run query 5000 times Andres Freund <andres@anarazel.de>
@ 2019-02-10 00:23   ` Ricardo Martin Gomez <rimartingomez@hotmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Ricardo Martin Gomez @ 2019-02-10 00:23 UTC (permalink / raw)
  To: Justin Pryzby <pryzby@telsasoft.com>; Andres Freund <andres@anarazel.de>; +Cc: Evandro Abreu <evandro.abreu@gmail.com>; pgsql-performance@lists.postgresql.org <pgsql-performance@lists.postgresql.org>

Hi,
Do you have an index in the date field?

Obtener Outlook para Android<https://aka.ms/ghei36;

________________________________
From: Andres Freund <andres@anarazel.de>
Sent: Saturday, February 9, 2019 5:23:14 PM
To: Justin Pryzby
Cc: Evandro Abreu; pgsql-performance@lists.postgresql.org
Subject: Re: slow to run query 5000 times

Hi,

On 2019-02-09 11:16:33 -0600, Justin Pryzby wrote:
> Please don't send images to the list, you can send a link to one of the image
> host websites if you need to describe something graphical.

FWIW, I don't agree with that policy. I plenty of time process email
while withoug internet, so I appreciate self contained email.

Greetings,

Andres Freund

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


end of thread, other threads:[~2019-02-10 00:23 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-02-09 17:16 Re: slow to run query 5000 times Justin Pryzby <pryzby@telsasoft.com>
2019-02-09 20:23 ` Andres Freund <andres@anarazel.de>
2019-02-10 00:23   ` Ricardo Martin Gomez <rimartingomez@hotmail.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