1

I need to execute a one-time task to update all rows in a large database. I want to do this as quickly as possible. Each row needs to be read, have a value in a column modified by an algorithm, and then updated with the transformed value. I have written a single partitioned stored procedure to do this.

I am aware of the examples on this page: https://docs.voltdb.com/UsingVoltDB/sysprocgetpartitionkeys.php

I would rather not have to write a java client to execute this procedure in each partition, and would ideally like to call @GetPartitionKeys, then execute the stored procedure on each value, in sqlcmd.

  • If it's only a one-time task, can't you just call @GetPartitionKeys in sqlcmd, and then just execute your procedure one at a time using all the partition keys? – Andrew Jul 18 '19 at 20:12
  • Apologies, it was badly phrased. When I said it’s a one-time task I meant it’s something that is only done once for a given DB instance but it will have to be done on lots of instances as part of a migration procedure. – Karlos TheJackal Jul 19 '19 at 21:39

1 Answers1

1

I found a way to do it using pipelines in bash:

echo "exec @GetPartitionKeys INTEGER;" | sqlcmd --output-skip-metadata | awk '{print $2}' | xargs -n 1 sh -c 'echo "exec YourPartitionedProcedure $0;" | sqlcmd'

This will take the partition key column and then execute YourPartitionedProcedure once for each partition key returned. You can add additional parameters as needed after the $0. You can switch INTEGER to STRING as needed as well.

Andrew
  • 311
  • 1
  • 8