Skip to content

Instantly share code, notes, and snippets.

@digi0ps
Last active April 21, 2020 04:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digi0ps/f70e9c1977633470055327a726f97b30 to your computer and use it in GitHub Desktop.
Save digi0ps/f70e9c1977633470055327a726f97b30 to your computer and use it in GitHub Desktop.
Shell script for testing Postgres with and without an active connection.
#! /bin/zsh
zmodload zsh/datetime
start=$EPOCHREALTIME
for i in {1..100};
do
PGPASSWORD=password psql -U localadmin testing -c "select count(*) from pg_stat_activity;" > /dev/null;
done
end=$EPOCHREALTIME
echo "Test 1 Elapsed Time: $((end-start))";
start=$EPOCHREALTIME
PGPASSWORD=password psql -U localadmin testing \
-c "DO
\$do\$
BEGIN
FOR i IN 1..100 LOOP
perform count(*) from pg_stat_activity;
END LOOP;
END
\$do\$;" > /dev/null;
end=$EPOCHREALTIME
echo "Test 2 Elapsed Time: $((end-start))";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment