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?
|
I would like to be able to generate random 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:
|
|||||||||||||||||
|
|
testbed:
function to return random binary strings:
output examples:
remove testbed:
|
|||||||
|