pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to know which queries are to be optimised?
7+ messages / 5 participants
[nested] [flat]

* How to know which queries are to be optimised?
@ 2004-08-04 12:00  Ulrich Wisser <ulrich.wisser@relevanttraffic.se>
  0 siblings, 1 reply; 7+ messages in thread

From: Ulrich Wisser @ 2004-08-04 12:00 UTC (permalink / raw)
  To: pgsql-general@postgresql.org

Hello,

my web application grows slower and slower over time. After some 
profiling I came to the conclusion that my SQL queries are the biggest 
time spenders (25 seconds). Obviously I need to optimise my queries and 
maybe introduce some new indexes.

The problem is, that my application uses dynamic queries. I therefor can 
not determine what are the most common queries.

I have used the postgresql logging ption before. Is there a tool to 
analyze the logfile for the most common and/or most time consuming queries?

TIA

Ulrich




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

* Re: How to know which queries are to be optimised?
@ 2004-08-11 16:27  Bruno Wolff III <bruno@wolff.to>
  parent: Ulrich Wisser <ulrich.wisser@relevanttraffic.se>
  0 siblings, 1 reply; 7+ messages in thread

From: Bruno Wolff III @ 2004-08-11 16:27 UTC (permalink / raw)
  To: Ulrich Wisser <ulrich.wisser@relevanttraffic.se>; +Cc: pgsql-general@postgresql.org; pgsql-performance

On Wed, Aug 04, 2004 at 14:00:39 +0200,
  Ulrich Wisser <ulrich.wisser@relevanttraffic.se> wrote:

This topic really belongs on the performance list. I have copied that
list and set followups to go there and copy you.

> 
> my web application grows slower and slower over time. After some 
> profiling I came to the conclusion that my SQL queries are the biggest 
> time spenders (25 seconds). Obviously I need to optimise my queries and 
> maybe introduce some new indexes.

This sounds like you aren't doing proper maintainance. You need to be
vacuuming with a large enough FSM setting.

> The problem is, that my application uses dynamic queries. I therefor can 
> not determine what are the most common queries.
> 
> I have used the postgresql logging ption before. Is there a tool to 
> analyze the logfile for the most common and/or most time consuming queries?

You can log queries that run for at least a specified amount of time.
This will be useful in finding what the long running queries are.
You can then use explain analyse to see why they are long running.



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

* Re: [GENERAL] How to know which queries are to be optimised?
@ 2004-08-12 10:37  Ulrich Wisser <ulrich.wisser@relevanttraffic.se>
  parent: Bruno Wolff III <bruno@wolff.to>
  0 siblings, 3 replies; 7+ messages in thread

From: Ulrich Wisser @ 2004-08-12 10:37 UTC (permalink / raw)
  To: pgsql-performance; +Cc: bruno@wolff.to

Hi Bruno,

>>my web application grows slower and slower over time. After some 
>>profiling I came to the conclusion that my SQL queries are the biggest 
>>time spenders (25 seconds). Obviously I need to optimise my queries and 
>>maybe introduce some new indexes.
> 
> This sounds like you aren't doing proper maintainance. You need to be
> vacuuming with a large enough FSM setting.

I do a vacuum full analyze every night.
How can I see if my FSM setting is appropriate?

>>The problem is, that my application uses dynamic queries. I therefor can 
>>not determine what are the most common queries.
>>
>>I have used the postgresql logging ption before. Is there a tool to 
>>analyze the logfile for the most common and/or most time consuming queries?
> 
> 
> You can log queries that run for at least a specified amount of time.
> This will be useful in finding what the long running queries are.
> You can then use explain analyse to see why they are long running.

But is there a tool that could compile a summary out of the log? The log 
grows awefully big after a short time.

Thanks

/Ulrich








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

* Re: [GENERAL] How to know which queries are to be optimised?
@ 2004-08-12 11:16  Richard Huxton <dev@archonet.com>
  parent: Ulrich Wisser <ulrich.wisser@relevanttraffic.se>
  2 siblings, 1 reply; 7+ messages in thread

From: Richard Huxton @ 2004-08-12 11:16 UTC (permalink / raw)
  To: Ulrich Wisser <ulrich.wisser@relevanttraffic.se>; +Cc: pgsql-performance; bruno@wolff.to

Ulrich Wisser wrote:
>> You can log queries that run for at least a specified amount of time.
>> This will be useful in finding what the long running queries are.
>> You can then use explain analyse to see why they are long running.
> 
> But is there a tool that could compile a summary out of the log? The log 
> grows awefully big after a short time.

You might want to look at the "Practical Query Analyser" - haven't used 
it myself yet, but it seems a sensible idea.

http://pqa.projects.postgresql.org/

-- 
   Richard Huxton
   Archonet Ltd



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

* Re: [GENERAL] How to know which queries are to be optimised?
@ 2004-08-12 14:07  Christopher Kings-Lynne <chriskl@familyhealth.com.au>
  parent: Ulrich Wisser <ulrich.wisser@relevanttraffic.se>
  2 siblings, 0 replies; 7+ messages in thread

From: Christopher Kings-Lynne @ 2004-08-12 14:07 UTC (permalink / raw)
  To: Ulrich Wisser <ulrich.wisser@relevanttraffic.se>; +Cc: pgsql-performance@postgresql.org, <bruno@wolff.to>

> I do a vacuum full analyze every night.
> How can I see if my FSM setting is appropriate?

On a busy website, run vacuum analyze once an hour, or even better, use
contrib/pg_autovacuum

Chris





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

* Re: [GENERAL] How to know which queries are to be optimised?
@ 2004-08-12 14:09  Christopher Kings-Lynne <chriskl@familyhealth.com.au>
  parent: Ulrich Wisser <ulrich.wisser@relevanttraffic.se>
  2 siblings, 0 replies; 7+ messages in thread

From: Christopher Kings-Lynne @ 2004-08-12 14:09 UTC (permalink / raw)
  To: Ulrich Wisser <ulrich.wisser@relevanttraffic.se>; +Cc: pgsql-performance@postgresql.org, <bruno@wolff.to>

> But is there a tool that could compile a summary out of the log? The log
> grows awefully big after a short time.

Actually, yes there is.  Check out www.pgfoundry.org.  I think it's called
pqa or postgres query analyzer or somethign.

Chris




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

* Re: [GENERAL] How to know which queries are to be optimised?
@ 2004-08-12 22:50  Rudi Starcevic <tech@wildcash.com>
  parent: Richard Huxton <dev@archonet.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Rudi Starcevic @ 2004-08-12 22:50 UTC (permalink / raw)
  To: pgsql-performance

Hi,

>> But is there a tool that could compile a summary out of the log? The 
>> log grows awefully big after a short time.

There's also pg_analyzer to check out.

http://www.samse.fr/GPL/pg_analyzer/

Some of it's features are: written in Perl and produces HTML output.

> You might want to look at the "Practical Query Analyser" - haven't used 
> it myself yet, but it seems a sensible idea.
> 
> http://pqa.projects.postgresql.org/


Cheers,
Rudi.



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


end of thread, other threads:[~2004-08-12 22:50 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-08-04 12:00 How to know which queries are to be optimised? Ulrich Wisser <ulrich.wisser@relevanttraffic.se>
2004-08-11 16:27 ` Bruno Wolff III <bruno@wolff.to>
2004-08-12 10:37   ` Ulrich Wisser <ulrich.wisser@relevanttraffic.se>
2004-08-12 11:16     ` Richard Huxton <dev@archonet.com>
2004-08-12 22:50       ` Rudi Starcevic <tech@wildcash.com>
2004-08-12 14:07     ` Christopher Kings-Lynne <chriskl@familyhealth.com.au>
2004-08-12 14:09     ` Christopher Kings-Lynne <chriskl@familyhealth.com.au>

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