Re: Fwd: different execution time for the same query (and same DB status)

2021-03-12 Thread Francesco De Angelis
I have re-tested the execution times with several different values of shared_buffers in the range 256 MB - 4 GB. It didn't solve the problem and I noticed that for values greater than 3GB the executions halt very frequently. I also tried to disable JIT and this further slowed it down. But there is

Re: Fwd: different execution time for the same query (and same DB status)

2021-03-10 Thread Francesco De Angelis
Hello, yes exactly in the previous analyses, as mentioned in the wiki, I ran EXPLAIN (ANALYZE, BUFFERS)* query*, which took much longer to complete (around 30 minutes) as showed in https://explain.depesz.com/s/gHrb and https://explain.depesz.com/s/X2as . As you said, I did the new tests with EXPLAI

Re: Fwd: different execution time for the same query (and same DB status)

2021-03-10 Thread Michael Lewis
I would increase shared_buffers to 1GB or more. Also, it would be very interesting to see these queries executed with JIT off.

Re: Fwd: different execution time for the same query (and same DB status)

2021-03-10 Thread Justin Pryzby
On Sat, Mar 06, 2021 at 10:40:00PM +0100, Francesco De Angelis wrote: > The problem is the following: the query can take between 20 seconds and 4 > minutes to complete. Most of times, when I run the query for the first time > after the server initialisation, it takes 20 seconds; but if I re-run it

Re: different execution time for the same query (and same DB status)

2021-03-10 Thread Francesco De Angelis
Hello, many thanks to all the persons who replied. I am back with the information requested in https://wiki.postgresql.org/wiki/Slow_Query_Questions. Here you can find the results of the EXPLAIN commands: 1) First execution: https://explain.depesz.com/s/X2as 2) Second execution (right after the fir

Re: different execution time for the same query (and same DB status)

2021-03-08 Thread Michael Lewis
You don't mention shared_buffers, which is quite low by default. Not sure of the memory of your docker container, but it might be prudent to increase shared_buffers to keep as much data as possible in memory rather than needing to read from disk by a second run. To test the possibility Tom Lane sug

Re: different execution time for the same query (and same DB status)

2021-03-07 Thread Tom Lane
Julien Rouhaud writes: > +1, and more generally please follow > https://wiki.postgresql.org/wiki/Slow_Query_Questions. Yeah. FWIW, the most likely explanation for the change in behavior is that by the time of the second execution, auto-analyze has managed to update the table's statistics, and th

Re: different execution time for the same query (and same DB status)

2021-03-07 Thread Julien Rouhaud
On Sun, Mar 07, 2021 at 03:51:05PM +0100, Michel SALAIS wrote: > > Have you tried to use EXPLAIN ANALYZE at least? > > It could give valuable information about why this is occurring. +1, and more generally please follow https://wiki.postgresql.org/wiki/Slow_Query_Questions.

RE: different execution time for the same query (and same DB status)

2021-03-07 Thread Michel SALAIS
Hi, Have you tried to use EXPLAIN ANALYZE at least? It could give valuable information about why this is occurring. Michel SALAIS De : Francesco De Angelis Envoyé : samedi 6 mars 2021 22:40 À : pgsql-performance@lists.postgresql.org Objet : Fwd: different execution time for the same

Fwd: different execution time for the same query (and same DB status)

2021-03-07 Thread Francesco De Angelis
Hi all, I would appreciate if somebody could help me understanding why the query described below takes very different execution times to complete, almost completely randomly. I have two very "simple" tables, A and B: CREATE TABLE A ( a1 varchar(10) NULL, a2 varchar(10) NULL, v int4 NULL ); CREATE