pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
To: David Jarvis <thangalin@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-performance@postgresql.org, Magnus Hagander <magnus@hagander.net>
Subject: Re: Analysis Function
Date: Sun, 13 Jun 2010 09:02:23 +0300
Message-ID: <4C14746F.9050603@enterprisedb.com> (raw)
In-Reply-To: <AANLkTinPNQZv_9BS1fkoLPXzcBZe8FFv77PBRhPR-GpL@mail.gmail.com>
References: <AANLkTikihIMleazgqo1NhLo7LA5Tiujz4TIfBL1agxAp@mail.gmail.com>
	<AANLkTikZKwBCR8QfGph3aH34A2dJ2NQyOjq-Pt3eZ3_z@mail.gmail.com>
	<4C119B3E.3090608@squeakycode.net>
	<AANLkTinjUmGWmB3jsjj-6w_44c0K7f_wSrH_1TALPaOY@mail.gmail.com>
	<m34ohahrp4.fsf@passepartout.tim-landscheidt.de>
	<AANLkTik3l6uedzVJLqn-nueNva46NAFwxbpSe1XSc26_@mail.gmail.com>
	<m3typ9hl6a.fsf@passepartout.tim-landscheidt.de>
	<AANLkTikPcYh1vMxVynxGnD4RCch8-DMixiGK1v9kO17Z@mail.gmail.com>
	<AANLkTim6TrfgLiXM3sTSx6rgXQ3zNLTWBTD_MbU0OPsv@mail.gmail.com>
	<12241.1276287655@sss.pgh.pa.us>
	<AANLkTil8w33uYIadqvvecTEvTmY9aNvstpuiy1tryyT7@mail.gmail.com>
	<AANLkTinPNQZv_9BS1fkoLPXzcBZe8FFv77PBRhPR-GpL@mail.gmail.com>

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



view thread (30+ messages)  latest in thread

Message-ID: <4C14746F.9050603@enterprisedb.com>
Permalink:  ../4C14746F.9050603@enterprisedb.com/
Also on:    postgresql.org/message-id/4C14746F.9050603@enterprisedb.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: heikki.linnakangas@enterprisedb.com, thangalin@gmail.com, tgl@sss.pgh.pa.us, magnus@hagander.net
  Subject: Re: Analysis Function
  In-Reply-To: <4C14746F.9050603@enterprisedb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox