Re: PgBench's \setrandom could be better

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PgBench's \setrandom could be better
Date: 2014-11-17 17:28:18
Message-ID: CA+Tgmoam5DS_xZtpoHp7B3iXxgDg2o_GWHCysQacFTVtkkgduQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Nov 15, 2014 at 5:51 PM, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> With pgbench I can do:
>
> \setrandom qty 24 25
> then throw a :qty into the query and have pgbench replace that with either
> 24 or 25.
>
> The problem is that this does not work for anything apart from integer
> types.

I've got a pending patch here - which I don't think anyone has
reviewed - that adds an expression syntax to pgbench:

https://commitfest.postgresql.org/action/patch_view?id=1581

Once that patch goes in, I think we should generalize it so that the
\set syntax can use not only operators but also functions, like abs().
We could also generalize it to work on data types other than integers,
such as strings or (like you're suggesting here) dates, so that you
could have a random_date() function.

In general I'm pretty skeptical about continuing to expend pgbench by
adding more backslash commands and complicating the syntax of the ones
we've already got. We can certainly do it that way, but it's kind of
a mess. I'd rather have a more general framework to build on.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2014-11-17 17:34:10 pgsql: Add --synchronous option to pg_receivexlog, for more reliable WA
Previous Message Tom Lane 2014-11-17 17:21:39 Re: [BUGS] ltree::text not immutable?