Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 3C661634B92 for ; Sun, 13 Jun 2010 03:03:41 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 89272-02-5 for ; Sun, 13 Jun 2010 06:03:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og112.obsmtp.com (exprod7og112.obsmtp.com [64.18.2.177]) by mail.postgresql.org (Postfix) with SMTP id A999C63F5EE for ; Sun, 13 Jun 2010 03:02:29 -0300 (ADT) Received: from source ([74.125.82.45]) by exprod7ob112.postini.com ([64.18.6.12]) with SMTP ID DSNKTBR0dGhbUlFxv64OIkyMtxaiZVOS5Myp@postini.com; Sat, 12 Jun 2010 23:02:29 PDT Received: by wwb34 with SMTP id 34so1482828wwb.32 for ; Sat, 12 Jun 2010 23:02:27 -0700 (PDT) Received: by 10.227.154.147 with SMTP id o19mr4054646wbw.112.1276408947529; Sat, 12 Jun 2010 23:02:27 -0700 (PDT) Received: from [192.168.1.117] (dsl-hkibrasgw2-ff7ac300-240.dhcp.inet.fi [88.195.122.240]) by mx.google.com with ESMTPS id u36sm24945170wbv.0.2010.06.12.23.02.24 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 12 Jun 2010 23:02:25 -0700 (PDT) Message-ID: <4C14746F.9050603@enterprisedb.com> Date: Sun, 13 Jun 2010 09:02:23 +0300 From: Heikki Linnakangas Organization: EnterpriseDB User-Agent: Mozilla/5.0 (X11; U; Linux i686; fi-FI; rv:1.9.1.9) Gecko/20100515 Iceowl/1.0b1 Icedove/3.0.4 MIME-Version: 1.0 To: David Jarvis CC: Tom Lane , pgsql-performance@postgresql.org, Magnus Hagander Subject: Re: Analysis Function References: <4C119B3E.3090608@squeakycode.net> <12241.1276287655@sss.pgh.pa.us> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-4.2 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3 X-Spam-Level: X-Archive-Number: 201006/225 X-Sequence-Number: 39081 On 11/06/10 23:38, David Jarvis wrote: > I added an explicit cast in the SQL: > > dateserial(extract(YEAR FROM > m.taken)::int,'||p_month1||','||p_day1||') d1, > dateserial(extract(YEAR FROM > m.taken)::int,'||p_month2||','||p_day2||') d2 > > The function now takes three integer parameters; there was no performance > loss. We had a little chat about this with Magnus. It's pretty surprising that there's no built-in function to do this, we should consider adding one. We could have a function like: construct_timestamp(year int4, month int4, date int4, hour int4, minute int4, second int4, milliseconds int4, timezone text) Now that we have named parameter notation, callers can use it to conveniently fill in only the fields needed: SELECT construct_timestamp(year := 1999, month := 10, date := 22); -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com