Skip site navigation (1) Skip section navigation (2)

Re: [GENERAL] more execution time

From: Richard Huxton <dev(at)archonet(dot)com>
To: ALÝ ÇELÝK <ali(at)verus(dot)com(dot)tr>
Cc: pgsql-benchmarks(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org,pgsql-performance(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: [GENERAL] more execution time
Date: 2005-03-11 13:05:28
Message-ID: 42319798.1060206@archonet.com (view raw or flat)
Thread:
Lists: pgsql-benchmarkspgsql-generalpgsql-performancepgsql-sql
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

In response to

pgsql-performance by date

Next:From: Joost KraaijeveldDate: 2005-03-11 13:45:12
Subject: What is the number of rows in explain?
Previous:From: Oleg BartunovDate: 2005-03-11 12:03:15
Subject: Re: Statistics not working??

pgsql-sql by date

Next:From: Edmund BaconDate: 2005-03-11 16:57:37
Subject: Conver bool to text
Previous:From: Juris ZeltinsDate: 2005-03-11 12:50:13
Subject: Re: pl/pgsql problem with return types

pgsql-benchmarks by date

Next:From: CNDate: 2005-03-24 10:35:08
Subject: Benchmarks of MySQL, MaxDB, PostgreSQL, and Oracle
Previous:From: AL ELKDate: 2005-03-11 11:54:56
Subject: more execution time

pgsql-general by date

Next:From: Dick DaviesDate: 2005-03-11 13:10:07
Subject: Re: PostgreSQL still for Linux only?
Previous:From: GIROIRE Nicolas (COFRAMI)Date: 2005-03-11 13:03:09
Subject: Convert Cursor to array

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group