This file contains hidden or 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
| import django_rq | |
| import rq | |
| import rq.registry | |
| from conf import settings | |
| conn = django_rq.get_connection() | |
| # Get all workers |
This file contains hidden or 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
| CREATE TEMPORARY TABLE temporary_table AS SELECT * FROM <my_table> WHERE <condition>; | |
| -- Remove any columns that will cause a constraint error when re-inserting the row | |
| ALTER TABLE temporary_table DROP COLUMN id; | |
| -- Re-insert 100 copies of the row with a new UUID | |
| INSERT INTO <my_table> SELECT uuid_generate_v4() AS id, temporary_table.* FROM temporary_table CROSS JOIN GENERATE_SERIES(1,100); |
This file contains hidden or 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
| SELECT | |
| psui.relname AS table_name, | |
| pg_size_pretty(pg_relation_size(psui.relid)) AS table_size, | |
| psui.indexrelname AS index_name, | |
| psui.idx_scan AS index_scans_count, | |
| pg_size_pretty(pg_relation_size(psui.indexrelid)) AS index_size, | |
| psut.idx_scan AS table_idx_scans_count, | |
| psut.seq_scan AS table_seq_scans_count, | |
| psut.seq_scan + psut.idx_scan AS table_scans_total | |
| FROM pg_stat_user_indexes AS psui |