PostgreSQL performance test script
In case you want to run a quick performance test (in simple terms of access to DB) on a PostgreSQL server, this can be done quickly through a python module called psycopg2. This is the python script I’ve used: #!/usr/bin/python3 import psycopg2 from psycopg2 import Error import time def create_connection(): """ create a database connection to a PostgreSQL database """ try: conn = psycopg2.connect( database="postgres", user="postgres", password="postgres", host="1.2.3.4", port="5432" ) print('Successfully Connected to PostgreSQL') return conn except Error as e: print(e) def check_table_exists(conn): """ check if a table exists in the PostgreSQL database """ cur = conn.cursor() cur.execute(f"SELECT 1;") def main(): # table_name = 'pg_auth_members' # create a database connection conn = create_connection() # check if table exists with conn: start_time = time.time() checks = 0 while True: check_table_exists(conn) checks += 1 elapsed_time = time.time() - start_time if elapsed_time > 0: tps = checks / elapsed_time print(f'Current TPS: {tps}') print (f'Current checks: {checks}') if __name__ == '__main__': main() In here you should update the database, user, password, host and port to something relevant to your environment. Everything else can stay the same. ...