Re: Queries within a function

От: ramasubramanian
Тема: Re: Queries within a function
Дата: ,
Msg-id: FA1CD592A1C54FFEAB399559CF12CC30@ramasubramanian
(см: обсуждение, исходный текст)
Ответ на: Queries within a function  (Mridula Mahadevan)
Список: pgsql-performance

Скрыть дерево обсуждения

Queries within a function  (Mridula Mahadevan, )
 Re: Queries within a function  (Pavel Stehule, )
 Re: Queries within a function  (Tom Lane, )
  Re: Queries within a function  (Mridula Mahadevan, )
 Re: Queries within a function  ("Ing. Marcos Orti­z Valmaseda", )
  Re: Queries within a function  (Mridula Mahadevan, )
 Re: Queries within a function  ("ramasubramanian", )
 Re: Queries within a function  (Віталій Тимчишин, )
  Re: Queries within a function  (Mridula Mahadevan, )

Hi,
Try using dynamic sql. Query will be faster in a function
regards
Ram
----- Original Message -----
From: "Mridula Mahadevan" <>
To: "Tom Lane" <>
Cc: <>
Sent: Wednesday, February 03, 2010 2:23 AM
Subject: Re: [PERFORM] Queries within a function


Tom,
 I cannot run execute because all these are temp tables with drop on auto
commit within a function. This should have something to do with running it
in a transaction, when I run them in autocommit mode (without a drop on
autocommit) the queries return in a few seconds.


-----Original Message-----
From: Tom Lane [mailto:]
Sent: Tuesday, February 02, 2010 11:28 AM
To: Mridula Mahadevan
Cc: 
Subject: Re: [PERFORM] Queries within a function

Mridula Mahadevan <> writes:
>  I am running a bunch of queries within a function, creating some temp
> tables and populating them. When the data exceeds say, 100k the queries
> start getting really slow and timeout (30 min). when these are run outside
> of a transaction(in auto commit mode), they run in a few seconds. Any
> ideas on what may be going on and any postgresql.conf parameters etc that
> might help?

I'll bet the function is caching query plans that stop being appropriate
once the table grows in size.  You might have to resort to using
EXECUTE, although if you're on 8.4 DISCARD PLANS ought to help too.

regards, tom lane

--
Sent via pgsql-performance mailing list ()
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance




В списке pgsql-performance по дате сообщения:

От: J Sisson
Дата:
Сообщение: Re: the jokes for pg concurrency write performance
От: Dimitri Fontaine
Дата:
Сообщение: Re: queries with subquery constraints on partitioned tables not optimized?