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

Re: Query is slow when executing in procedure

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Query is slow when executing in procedure
Date: 2009-11-24 06:15:52
Message-ID: 20091124061552.GA30941@a-kretschmer.de (view raw or flat)
Thread:
Lists: pgsql-performance
In response to ramasubramanian :
> Dear all,
>     The query is slow when executing in the stored procedure(it is taking
> around 1 minute). when executing as a sql it is taking 4 seconds.
> basically i am selecting the varchar column which contain 4000 character. We
> have as iindex on the table. We have analyzed the table also. What could be the
> reason. How to improve it?

The reason is hard to guess, because you don't provide enough
informations like the function code.

My guess:

You calls the function with a parameter, and the planner isn't able to
chose a fast plan because he doesn't know the parameter. That's why he
is choosen a seq-scan. You can rewrite your function to using dynamical
execute a string that contains your sql to force the planner search an
optimal plan for your actual parameter.

But yes, that's only a wild guess (and sorry about my english...)

Please, show us the table and the function-code.


Regards, Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99

In response to

Responses

pgsql-performance by date

Next:From: ramasubramanianDate: 2009-11-24 06:29:09
Subject: Re: Query is slow when executing in procedure
Previous:From: Pavel StehuleDate: 2009-11-24 06:10:54
Subject: Re: Query is slow when executing in procedure

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