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
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-benchmarks pgsql-general pgsql-performance pgsql-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

Browse pgsql-benchmarks by date

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

Browse pgsql-general by date

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

Browse pgsql-performance by date

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

Browse pgsql-sql by date

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