Skip to content

Instantly share code, notes, and snippets.

@mesuutt
Last active November 9, 2021 19:09
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 mesuutt/38b43a69a69f0877fbab2c0ca31071a9 to your computer and use it in GitHub Desktop.
Save mesuutt/38b43a69a69f0877fbab2c0ca31071a9 to your computer and use it in GitHub Desktop.
Kullanisli Postgresql Sorgulari

https://gist.github.com/rgreenjr/3637525

5DK'dan fazla zamandir calisan queryleri bulma:

SELECT
  pid,
  now() - pg_stat_activity.query_start AS duration,
  query,
  state
FROM pg_stat_activity
WHERE (now() - pg_stat_activity.query_start) > interval '5 minutes';

Postgresql PID'ini cancel etme ve öldürme:

SELECT pg_cancel_backend(__pid__);
SELECT pg_terminate_backend(__pid__);

cancel/terimate farki

5DK'dan uzun suredir calisan tum queryleri iptal et:

SELECT pg_cancel_backend(pid) FROM pg_stat_activity 
WHERE (now() - pg_stat_activity.query_start) > interval '5 minutes';

Iki tarih araligi ile kesisen kayitlari bulmaca:

  • OVERLAPS operator, bak

Guzel yazilar

Komut Açıklama
\l Databaseleri listeleme
\c Database degistirme
\dt Tabloları listele
\x Sonuçları dikey gösterme aç/kapa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment