Skip to content

Instantly share code, notes, and snippets.

@mesuutt
Last active Nov 9, 2021
Embed
What would you like to do?
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