Re: Analysis Function - Mailing list pgsql-performance

From Heikki Linnakangas
Subject Re: Analysis Function
Date
Msg-id 4C14746F.9050603@enterprisedb.com
Whole thread Raw
In response to Re: Analysis Function  (David Jarvis <thangalin@gmail.com>)
Responses Re: Analysis Function  (David Jarvis <thangalin@gmail.com>)
Re: Analysis Function  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-performance
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

pgsql-performance by date:

Previous
From: Greg Smith
Date:
Subject: Re: ~400 TPS - good or bad?
Next
From: David Jarvis
Date:
Subject: Re: Analysis Function