Re: PgBench's \setrandom could be better

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: PgBench's \setrandom could be better
Дата
Msg-id CA+Tgmoam5DS_xZtpoHp7B3iXxgDg2o_GWHCysQacFTVtkkgduQ@mail.gmail.com
обсуждение исходный текст
Ответ на PgBench's \setrandom could be better  (David Rowley <dgrowleyml@gmail.com>)
Список pgsql-hackers
On Sat, Nov 15, 2014 at 5:51 PM, David Rowley <dgrowleyml@gmail.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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [BUGS] ltree::text not immutable?
Следующее
От: Fujii Masao
Дата:
Сообщение: Re: pg_receivexlog --status-interval add fsync feedback