I would like to be able to generate random
bytea fields of arbitrary length (<1Gb) for populating test data.
What is the best way of doing this?
Enhancing Jack Douglas's answer to avoid the need for PL/PgSQL looping and bytea concatenation, you can use:
It's a simple
The difference in performance due to the changed aggregation method is immense for larger
Or use a C extension function:
I've implemented a random bytea generator as a simple C extension function. It's in my scrapcode repository on GitHub. See the README there.
It nukes the performance of the above SQL version:
|show 7 more comments|
function to return random binary strings: