Comment on How to create a 1M record table with a single queryparentComments−jeffbee5yIf you're running PostgreSQL you can also just xxd -ps -c 16 -l $bignum < /dev/urandom | (echo '\copy random_data from stdin'; cat) | psql Depending on how you want your random keys formatted.−em5005yIf you're importing from command line tools, you might as well use the specialized `shuf` tool: shuf -i 1-$bignum or for random numbers with replacement shuf -i 1-$bignum -r -n $bignum These give you a sample of random integers. `shuf` is part of GNU coreutils, so present in most Linux installs (but not on macOS).−fouc5yIt's worth installing GNU coreutils on macOs All the command names are prepended with g, so `gshuf`−jeffbee5yNice yeah that's a good way. Generally the number 1 million is so small I see no reason to do this in any manner other than shell commands.
Comments
If you're running PostgreSQL you can also just
Depending on how you want your random keys formatted.If you're importing from command line tools, you might as well use the specialized `shuf` tool:
or for random numbers with replacement These give you a sample of random integers. `shuf` is part of GNU coreutils, so present in most Linux installs (but not on macOS).It's worth installing GNU coreutils on macOs All the command names are prepended with g, so `gshuf`
Nice yeah that's a good way. Generally the number 1 million is so small I see no reason to do this in any manner other than shell commands.