Re: [PATCH] Generate random dates/times in a specified range

From: Robert Treat <rob(at)xzilla(dot)net>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Greg Sabino Mullane <htamfids(at)gmail(dot)com>, Damien Clochard <damien(at)dalibo(dot)info>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Generate random dates/times in a specified range
Date: 2025-07-15 03:48:50
Message-ID: CABV9wwPE6K2Duhc0VVXXCt8PSfzJuHJKdGxZTUkb-FPnVcGm4Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jul 14, 2025 at 3:21 AM Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
> On Sat, 12 Jul 2025 at 16:15, Greg Sabino Mullane <htamfids(at)gmail(dot)com> wrote:
> >
> > I like the idea, especially the date variant. Unlike Tom, I'm not particularly concerned about breakage of existing scripts, as
> > most already are working just fine with raw numbers and I don't see this patch breaking them.
> >
> > In a selfish vein, I would use the "date" and timestamp variants a lot. I would use the "time" ones seldom to never.
>
> But it's completely trivial to emulate random(min_date, max_date), just by doing
>
> min_date + random(0, max_date - min_date)
>
> Is it really worth adding a core function for that?
>

I feel like this is a very similar argument against what was
ultimately the addition of timestamp based generate_series functions,
and similarly I think adding these in would be a rather useful
improvement for users, though like generate_series, we don't need to
hit every different data type (no one should ever generate a random
timetz for instance).

Robert Treat
https://xzilla.net

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2025-07-15 04:16:11 Re: speedup COPY TO for partitioned table.
Previous Message Tom Lane 2025-07-15 03:37:10 Re: ScanKeys passed to table_beginscan in SeqNext