Last active
October 24, 2019 01:30
-
-
Save nbenns/f5636bc8e281aa3ea06ddf27c3fd30ff to your computer and use it in GitHub Desktop.
DB Queries
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
-- MySQL count same queries | |
SELECT substring_index(info, '/', 1), count(*) AS cnt | |
FROM INFORMATION_SCHEMA.PROCESSLIST | |
WHERE INFO IS NOT NULL | |
GROUP BY 1 | |
HAVING cnt>1 | |
ORDER BY cnt DESC; | |
-- MySQL show queries on DB | |
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE DB='DB_NAME' | |
-- Show locks | |
SHOW OPEN TABLES WHERE In_use > 1; | |
-- POSTGRES -- | |
-- Set search path | |
set search_path to public,other; | |
-- Storage Size of DB | |
SELECT pg_size_pretty( pg_database_size('db_name') ); | |
-- Storage Size of Table | |
SELECT pg_size_pretty( pg_total_relation_size('table_name') ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment