Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 3AC8A37C728 for ; Thu, 9 Oct 2008 12:08:01 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 93644-01 for ; Thu, 9 Oct 2008 12:08:00 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by postgresql.org (Postfix) with ESMTP id A547E37C709 for ; Thu, 9 Oct 2008 12:08:00 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.1/8.14.1) with ESMTP id m99F7xQS008554 for ; Thu, 9 Oct 2008 12:07:59 -0300 (ADT) (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.14.1/8.14.1/Submit) id m99ElDbk086905 for pgsql-performance@postgresql.org; Thu, 9 Oct 2008 11:47:13 -0300 (ADT) (envelope-from news) From: "Sabin Coanda" X-Newsgroups: pgsql.performance Subject: low performance on functions returning setof record Date: Thu, 9 Oct 2008 17:47:30 +0300 Organization: Hub.Org Networking Services Lines: 24 Message-ID: X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 To: pgsql-performance@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200810/44 X-Sequence-Number: 31625 Hi there, I use different functions returning setof record, and they are working well. The problem is the performance when I use those functions in joins, for instance: SELECT * FROM "Table1" t1 JOIN "Function1"( a1, a2, ... aN ) AS f1( ColA int4, ColB varchar, ... ) ON t1.ColX = f1.ColA The problem is I'm not able to make indexes on the function, even inside I have just another select statement from different permanent tables, with some where clauses depending on the function arguments. Do you know a way to build such a function, returning something I can join in an outer select statement like above, using indexes or another way to run it faster ? TIA, Sabin