pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: ALÝ ÇELÝK <ali@verus.com.tr>
Cc: pgsql-benchmarks@postgresql.org
Cc: pgsql-general@postgresql.org
Cc: pgsql-performance@postgresql.org
Cc: pgsql-sql@postgresql.org
Subject: Re: [GENERAL] more execution time
Date: Fri, 11 Mar 2005 13:05:28 +0000
Message-ID: <42319798.1060206@archonet.com> (raw)
In-Reply-To: <d0s0uj$17l$2@news.hub.org>
References: <d0s0uj$17l$2@news.hub.org>

ALÝ ÇELÝK wrote:
> why this query needs more time?  Its very slow

Difficult to say for sure - could you provide the output of EXPLAIN 
ANALYSE rather than just EXPLAIN?

Some other immediate observations:
1. Perhaps don't post to so many mailing lists at once. If you reply to 
this, maybe reduce it to pgsql-performance?
2. You don't say whether the row estimates are accurate in the EXPLAIN.
3. You seem to be needlessly coalescing personaldetails.masterid since 
you check for it being null in your WHERE clause
4. Do you really need to cast to numeric and generate a "sorting" column 
that you then don't ORDER BY?
5. Is ppid an id number? And are you sure it's safe to calculate it like 
that?
6. What is balance() and how long does it take to calculate its result?

> select
>       coalesce(personaldetails.masterid::numeric,personaldetails.id) +
> (coalesce(personaldetails.id::numeric,0)/1000000) as sorting,
>       floor(coalesce(personaldetails.masterid::numeric,personaldetails.id) +
> (coalesce(personaldetails.id::numeric,0)/1000000)) as ppid,

>       balance('MASTER-REGISTRATION',personaldetails.id) as balance,

>       balance('MASTER-REGISTRATION',pd2.id) as accbalance,

I'm guessing point 6 is actually your problem - try it without the calls 
to balance() and see what that does to your timings.
--
   Richard Huxton
   Archonet Ltd



Message-ID: <42319798.1060206@archonet.com>
Permalink:  ../42319798.1060206@archonet.com/
Also on:    postgresql.org/message-id/42319798.1060206@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dev@archonet.com, ali@verus.com.tr, pgsql-benchmarks@postgresql.org, pgsql-general@postgresql.org, pgsql-performance@postgresql.org
  Subject: Re: [GENERAL] more execution time
  In-Reply-To: <42319798.1060206@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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