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
6. What is balance() and how long does it take to calculate its result?
> 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.
In response to
pgsql-performance by date
|Next:||From: Joost Kraaijeveld||Date: 2005-03-11 13:45:12|
|Subject: What is the number of rows in explain?|
|Previous:||From: Oleg Bartunov||Date: 2005-03-11 12:03:15|
|Subject: Re: Statistics not working??|
pgsql-sql by date
|Next:||From: Edmund Bacon||Date: 2005-03-11 16:57:37|
|Subject: Conver bool to text|
|Previous:||From: Juris Zeltins||Date: 2005-03-11 12:50:13|
|Subject: Re: pl/pgsql problem with return types|
pgsql-benchmarks by date
|Next:||From: CN||Date: 2005-03-24 10:35:08|
|Subject: Benchmarks of MySQL, MaxDB, PostgreSQL, and Oracle|
|Previous:||From: AL ELK||Date: 2005-03-11 11:54:56|
|Subject: more execution time|
pgsql-general by date
|Next:||From: Dick Davies||Date: 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|