Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id AAEBC1D7F817 for ; Sat, 10 Dec 2011 21:27:31 -0400 (AST) Received: from mail-iy0-f174.google.com ([209.85.210.174]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RZYCQ-0003ZV-Ky for pgsql-performance@postgresql.org; Sun, 11 Dec 2011 01:27:31 +0000 Received: by iaeh11 with SMTP id h11so968490iae.19 for ; Sat, 10 Dec 2011 17:27:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=QkfzTAYZSeT7ifpceWywc1rD07/xc+DRXI01/vXPTKE=; b=DpkMrZ67/igWJooUJg6NbQ2Te/cAbpnYKJiy2k3/ksPnj/Jrq7r4vrRIJCIae2sDp+ RRSc0ut8jE6I9Ncgf4Ka4y9uyhsuVAO3p+qL2kik4avl8tQcS7AoA+Otk4/IbXjoB+FP Qp3r8F3QE88ChJvUTcbAds3De55x6NN16cINc= MIME-Version: 1.0 Received: by 10.42.147.6 with SMTP id l6mr7539224icv.17.1323566838218; Sat, 10 Dec 2011 17:27:18 -0800 (PST) Received: by 10.50.213.34 with HTTP; Sat, 10 Dec 2011 17:27:18 -0800 (PST) In-Reply-To: <4EE3F060.6000602@fuzzy.cz> References: <4EE39620.5020703@fuzzy.cz> <4EE3F060.6000602@fuzzy.cz> Date: Sat, 10 Dec 2011 23:27:18 -0200 Message-ID: Subject: Re: Common slow query reasons - help with a special log From: Daniel Cristian Cruz Cc: pgsql-performance@postgresql.org Content-Type: multipart/alternative; boundary=90e6ba6e82fe3a801504b3c6eb26 X-Pg-Spam-Score: -1.6 (-) X-Archive-Number: 201112/85 X-Sequence-Number: 45884 --90e6ba6e82fe3a801504b3c6eb26 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2011/12/10 Tomas Vondra > On 10.12.2011 23:40, Daniel Cristian Cruz wrote: > > At work we have a 24 cores server, with a load average around 2.5. > > A single query is processes by a single CPU, so even if the system is > not busy a single query may hit CPU bottleneck. The real issue is the > instrumentation overhead - timing etc. On some systems (with slow > gettimeofday) this may be a significant problem as the query hits the > CPU boundary sooner. > Yes, I forgot it will run on the same PID. Since analyze will cause all queries to slow down, maybe the 24 cores could became overloaded. > > > I don't know yet if a system which use some unused CPU to minimize the > > load of a bad query identified early is bad or worse. > > Not really, due to the "single query / single CPU" rule. I guess it will be a nice tool to run in the validation server. > > Indeed, I don't know if my boss would let me test this at production > > too, but it could be good to know how things work in "auto-pilot" mode. > > What I was pointing out is that you probably should not enable loggin > "explain analyze" output by "auto_explain.log_analyze =3D true". There ar= e > three levels of detail: > > 1) basic, just log_min_duration_statement > > 2) auto_explain, without 'analyze' - just explain plain > > 3) auto_explain, with 'analyze' - explain plan with actual values > > Levels (1) and (2) are quite safe (unless the minimum execution time is > too low). > I would start with 5 seconds. Reading the manual again and I saw that enabling analyze, it analyze all queries, even the ones that wasn't 5 second slower. And understood that there is no way to disable for slower queries, since there is no way to know it before it ends... I read Bruce blog about some features going to multi-core. Could explain analyze go multi-core too? Another thing I saw is that I almost never look at times in explain analyze. I always look for rows divergence and methods used for scan and joins when looking for something to get better performance. I had the nasty idea of putting a // before de gettimeofday in the code for explain analyze (I guess it could be very more complicated than this). Sure, its ugly, but I think it could be an option for an explain analyze "with no time", and in concept, it's what I'm looking for. --=20 Daniel Cristian Cruz =E3=82=AF=E3=83=AB=E3=82=BA =E3=82=AF=E3=83=AA=E3=82=B9=E3=83=81=E3=82=A2= =E3=83=B3 =E3=83=80=E3=83=8B=E3=82=A8=E3=83=AB --90e6ba6e82fe3a801504b3c6eb26 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
2011/12/10 Tomas Vondra <tv@fuzzy.cz>
On 10.12.2011 23:40, Daniel Cristian Cruz wrote:
> At work we have a 24 cores server, with a load average around 2.5.

A single query is processes by a single CPU, so even if the system is=
not busy a single query may hit CPU bottleneck. The real issue is the
instrumentation overhead - timing etc. On some systems (with slow
gettimeofday) this may be a significant problem as the query hits the
CPU boundary sooner.

Yes, I forgot it w= ill run on the same PID. Since analyze will cause all queries to slow down,= maybe the 24 cores could became overloaded.
=C2=A0

> I don't know yet if a system which use some unused CPU to minimize= the
> load of a bad query identified early is bad or worse.

Not really, due to the "single query / single CPU" rule.

I guess it will be a nice tool to run in the = validation server.=C2=A0
=C2=A0
> Indeed, I don't know if my boss would let me test this at producti= on
> too, but it could be good to know how things work in "auto-pilot&= quot; mode.

What I was pointing out is that you probably should not enable loggin=
"explain analyze" output by "auto_explain.log_analyze =3D tr= ue". There are
three levels of detail:

1) basic, just log_min_duration_statement

2) auto_explain, without 'analyze' - just explain plain

3) auto_explain, with 'analyze' - explain plan with actual values
Levels (1) and (2) are quite safe (unless the minimum execution time is
too low).

I would start with 5 seconds.=

Reading the manual again and I saw that enabling = analyze, it analyze all queries, even the ones that wasn't 5 second slo= wer. And understood that there is no way to disable for slower queries, sin= ce there is no way to know it before it ends...

I read Bruce blog about some features going to multi-co= re. Could explain analyze go multi-core too?

Anoth= er thing I saw is that I almost never look at times in explain analyze. I a= lways look for rows divergence and methods used for scan and joins when loo= king for something to get better performance.

I had the nasty idea of putting a // before de=C2=A0get= timeofday in the code for explain analyze (I guess it could be very more co= mplicated than this).

Sure, its ugly, but I think = it could be an option for an explain analyze "with no time", and = in concept, it's what I'm looking for.

--
Daniel Cristian Cruz
=E3=82=AF=E3=83=AB=E3= =82=BA =E3=82=AF=E3=83=AA=E3=82=B9=E3=83=81=E3=82=A2=E3=83=B3 =E3=83=80=E3= =83=8B=E3=82=A8=E3=83=AB
--90e6ba6e82fe3a801504b3c6eb26--