Created
October 30, 2023 17:25
-
-
Save avernet/6d1596728dee6d7da0ee05a7b61affbf to your computer and use it in GitHub Desktop.
For PostgreSQL, create 1k rows with 10k of random text each
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH RECURSIVE random_chars AS ( | |
SELECT | |
1 AS id, | |
1 AS group_id, | |
substr( | |
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', | |
floor(random() * 62)::int + 1, | |
1 | |
) AS char | |
UNION ALL | |
SELECT | |
CASE | |
WHEN id < 10000 THEN id + 1 | |
ELSE 1 | |
END AS id, | |
CASE | |
WHEN id < 10000 THEN group_id | |
ELSE group_id + 1 | |
END AS group_id, | |
substr( | |
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', | |
floor(random() * 62)::int + 1, | |
1 | |
) | |
FROM random_chars | |
WHERE group_id < 1000 | |
), | |
aggregated_chars AS ( | |
SELECT | |
group_id, | |
string_agg(char, '') AS random_string | |
FROM random_chars | |
GROUP BY group_id | |
) | |
INSERT INTO orbeon_form_data | |
(form_version, deleted, draft, | |
xml) | |
SELECT | |
1, 'N', 'N', | |
('<_>' || random_string || '</_>')::xml | |
FROM aggregated_chars; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment