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
{ | |
"[python]": { | |
"editor.codeActionsOnSave": { | |
"source.fixAll": true, | |
"source.organizeImports": true, | |
"source.unusedImports": true | |
}, | |
"editor.defaultFormatter": "ms-python.black-formatter", | |
"editor.formatOnSave": true, | |
"editor.formatOnType": true |
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
WITH raw_data AS ( | |
SELECT | |
pg_namespace.nspname, | |
pg_class.relname, | |
pg_class.oid AS relid, | |
pg_class.reltuples, | |
pg_stat_all_tables.n_dead_tup, | |
pg_stat_all_tables.n_mod_since_analyze, | |
(SELECT split_part(x, '=', 2) FROM unnest(pg_class.reloptions) q (x) WHERE x ~ '^autovacuum_analyze_scale_factor=' ) as c_analyze_factor, | |
(SELECT split_part(x, '=', 2) FROM unnest(pg_class.reloptions) q (x) WHERE x ~ '^autovacuum_analyze_threshold=' ) as c_analyze_threshold, |
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
-- https://gitlab.com/-/snippets/2138417 | |
select | |
now(), | |
query_start as started_at, | |
now() - query_start as query_duration, | |
format('[%s] %s', a.pid, a.query) as pid_and_query, | |
index_relid::regclass as index_name, | |
relid::regclass as table_name, | |
(pg_size_pretty(pg_relation_size(relid))) as table_size, | |
nullif(wait_event_type, '') || ': ' || wait_event as wait_type_and_event, |
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 OR REPLACE VIEW pg_size AS ( | |
SELECT | |
a.table_name AS name, | |
a.row_estimate :: INTEGER AS row_estimate, | |
pg_size_pretty(a.total_bytes) AS total, | |
pg_size_pretty(a.table_bytes) AS "table", | |
pg_size_pretty(a.index_bytes) AS index, | |
pg_size_pretty(a.toast_bytes) AS toast | |
FROM (SELECT | |
a_1.oid, |
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
from twisted.internet.task import react | |
from twisted.internet.defer import Deferred | |
from twisted.internet.protocol import Factory, connectionDone | |
from twisted.internet.endpoints import TCP4ServerEndpoint | |
from twisted.protocols.basic import LineReceiver | |
class ChatProtocol(LineReceiver): | |
def lineReceived(self, line): | |
self.factory.send_message(self, line) |
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
var dbs_names = db.adminCommand('listDatabases'); | |
for (var i = 0; i < dbs_names.databases.length; i += 1) { | |
var current_db = connect(dbs_names.databases[i].name); | |
var collection_names = current_db.getCollectionNames(); | |
for (var j = 0; j < collection_names.length; j += 1) { | |
var collection = current_db[collection_names[j]]; | |
var size = collection.stats().count; | |
print(dbs_names.databases[i].name + '\t' + collection_names[j] + ':\t' + size); | |
}; | |
}; |
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
from twisted.internet import reactor | |
import zmq | |
from txzmq import ZmqEndpoint, ZmqFactory, ZmqConnection, ZmqEndpointType | |
REQUEST_COUNT = 10000 | |
EVENTS_COUNT = 20000 - 2 | |
class NewConnection(ZmqConnection): |