Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id BD4CE1337B4E for ; Thu, 23 Dec 2010 13:03:44 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 78073-03 for ; Thu, 23 Dec 2010 17:03:37 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.anarazel.de (mail.anarazel.de [217.115.131.40]) by mail.postgresql.org (Postfix) with ESMTP id 78E251337B49 for ; Thu, 23 Dec 2010 13:03:37 -0400 (AST) Received: from alap2.localnet (p549F64CE.dip.t-dialin.net [84.159.100.206]) by mail.anarazel.de (Postfix) with ESMTPSA id 4D101448003; Thu, 23 Dec 2010 18:03:35 +0100 (CET) From: Andres Freund To: pgsql-performance@postgresql.org Subject: Re: Create index on subfield returned by function that returns base type with sub fields Date: Thu, 23 Dec 2010 18:03:33 +0100 User-Agent: KMail/1.13.5 (Linux/2.6.36-rc6-andres-00006-g4193d91; KDE/4.5.1; x86_64; ; ) Cc: Desmond Coertzen References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201012231803.33978.andres@anarazel.de> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201012/293 X-Sequence-Number: 41745 Hi, On Thursday 23 December 2010 17:53:24 Desmond Coertzen wrote: > Is is possible to create an index on a field on a function that returns a > data type that contains subfields? > Is this possible? How would I write the statement? I am not sure I understood you correctly. Maybe you mean something like that: test=# CREATE FUNCTION blub(IN int, OUT a int, OUT b int) RETURNS record IMMUTABLE LANGUAGE sql AS $$SELECT $1+1, $1+2$$; CREATE FUNCTION Time: 1.665 ms test=# CREATE INDEX foo__blub ON foo (((blub(data)).a)); CREATE INDEX Time: 86.393 ms Btw, this is the wrong list for this sort of question. The right place would be -general. Andres