pgbench: introduce a new automatic variable 'client_number'
pgbench: introduce a new automatic variable 'client_number'
Please find attached a patch for pgbench that introduces a new auto-variable 'client_number'. Following in the footsteps of 'scale' auto-variable, this is not declared if the user has specified this variable using -D switch.
Since 'clientid' is a very common name a user can use for their own script's variable, I chose to call this auto-variable client_number; just to avoid conflicts.
This variable can come in handy when you want to use a different expression in a query depending on which client is executing it. An example custom transaction is attached, where the UPDATE statement from any given client always updates the same logical row.
Best regards,
--
Since 'clientid' is a very common name a user can use for their own script's variable, I chose to call this auto-variable client_number; just to avoid conflicts.
This variable can come in handy when you want to use a different expression in a query depending on which client is executing it. An example custom transaction is attached, where the UPDATE statement from any given client always updates the same logical row.
Best regards,
--
Re: pgbench: introduce a new automatic variable 'client_number'
On 06.06.2013 06:53, Gurjeet Singh wrote: > Please find attached a patch for pgbench that introduces a new > auto-variable 'client_number'. Following in the footsteps of 'scale' > auto-variable, this is not declared if the user has specified this variable > using -D switch. > > Since 'clientid' is a very common name a user can use for their own > script's variable, I chose to call this auto-variable client_number; just > to avoid conflicts. Hmm, I'm not sure I care too much about that, to be honest. We have 'scale' as an auto-variable as well, which is also a common word. Also, if there's an existing script out there that does "\set client_id ...", it will override the automatic value, and work as it used to. Another reason to name it "client_id" is that in the pgbench -l log format, the documentation calls the first column "client_id". Makes sense to call the auto-variable the same. I think you forgot to compile with the patch, because there's a semicolon missing ;-). I moved the code around a bit, setting the variable next to where :scale is set; that's more readable. In the docs, I split the descriptions of :scale and :client_id into a table. I'll commit the attached as soon as the tree opens for 9.4 development. - Heikki