Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bIJoS-0007qq-1G for pgsql-performance@arkaria.postgresql.org; Wed, 29 Jun 2016 18:02:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bIJoR-0000VX-Gu for pgsql-performance@arkaria.postgresql.org; Wed, 29 Jun 2016 18:02:11 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) id 1bIJoQ-0000Sr-FY for pgsql-performance@postgresql.org; Wed, 29 Jun 2016 18:02:10 +0000 Received: from [2607:ff10:c5:506:225:90ff:feab:5c2e] (helo=gourmet8.spamgourmet.com) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) id 1bIJoJ-00040A-IJ for pgsql-performance@postgresql.org; Wed, 29 Jun 2016 18:02:09 +0000 Received: from spamgourmet by gourmet7.spamgourmet.com with local (Exim 4.80) (envelope-from ) id 1bIJoH-0007Uh-5S for pgsql-performance@postgresql.org; Wed, 29 Jun 2016 18:02:01 +0000 Received: from mail-lf0-f53.google.com ([209.85.215.53]) by gourmet7.spamgourmet.com with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1bIJoG-0007TI-QB for ; Wed, 29 Jun 2016 18:02:01 +0000 Received: by mail-lf0-f53.google.com with SMTP id h129so38968350lfh.1 for <>; Wed, 29 Jun 2016 11:02:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=2MrEGBKrfnNL+4hRNjy6vFtSj/q/iweRA4Jr4/xkxyI=; b=BWgpDit7Gy/lkczBJFK31J2Bxo90Xr9QHIT27RO1+gCY3EX7GiaCHtZ9KzLyqlH5q8 6+ZsfhDbi2VZLsGZyF8LSWKsgENLPSDTFbTXLTisjDZDO5UKjfIegNxwQpaFpH40HEKK QRS2fu9w5uwZDaJAtEY4lNqaCpPbqlzvVCCRfSVJFRxWp29lbpIcFJ5RyPv7JVs200MZ 74Kd6EYdG/pS/xNOcvc7eB/NzyF1pni+0hipbhfbdmP057aUPkx0XlAi/IlPAGHyLyS9 2Yv604Kzz+3uE0wJm1nM6BEPp3ulKw7wYyTPHJTWIRKeIJhGOLQMe0Ln+xIFW9vd/U7w HPdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=2MrEGBKrfnNL+4hRNjy6vFtSj/q/iweRA4Jr4/xkxyI=; b=HnaPUgKRexfoSxHyruUdOVEORJgAypgSKfbBZ8s0Q/v0Np99zGN5b0qOeub0StQoMv 3WtwV5nykouFZnkOAGQkFCtfUuRxzUgTSRsUtZopJ7n3wXVi8C838WywTYEjUUgZk9FW 89LX7mDXxym2g0p7cAl69wZwUq8uzPID5kQ6NsgENLBR6R6E81ijvbMqwLWEtjIKVi1h NQtpuv7JxzKpsWaVj2n3aYwzf7oCeOKY0ossQMTny8dqPJCQsM4At9y7gLD+njwL68Od dU4gc3SClK6Sfl07DekVVLIXZGAiaae+un+k62IaKNaYO3Xkostl63cxihBx4BtytQwk FL8Q== X-Gm-Message-State: ALyK8tKiEw9IQmwlYtLyIFo+tTszSOhbZwmeHEmCaUzJOj6aCrTrJDX1Pwt6Ke4JW3RsexET1dE96VsT2QLJVA== X-Received: by 10.25.146.209 with SMTP id u200mr3227494lfd.224.1467223318638; Wed, 29 Jun 2016 11:01:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.25.154.76 with HTTP; Wed, 29 Jun 2016 11:01:38 -0700 (PDT) In-Reply-To: References: From: devel.brain99@xoxy.net Date: Wed, 29 Jun 2016 20:01:38 +0200 Message-ID: Subject: Re: Random slow queries To: pgsql-performance@postgresql.org Content-Type: text/plain; charset=UTF-8 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:ff10:c5:506:225:90ff:feab:5c2e (deferred) X-Pg-Spam-Score: -1.0 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 29 June 2016 at 14:45, Kevin Grittner wrote: > Please monitor for the start of such an event and capture the full > contents of pg_stat_activity and pg_locks during that 2 minute > window. I had already looked at that manually and found nothing unusual. To be more thorough, I now had a batch file log the contents of pg_stat_activity and pg_locks every 5 seconds. During my test run, there was one offending query invocation, a simple SELECT * FROM job WHERE field = $1 Of course the actual query specified the list of fields as it was generated by Hibernate, but that is what it boils down to - no joins etc. The column on which was queried is a VARCHAR(64) NOT NULL, not unique nor indexed (though in practice most values are unique). I can of course post the full output somewhere if you want (though it's more than 1000 lines). In the meantime, here is what I can gather from the output for these 2 minutes: 1) Looking at the logged pg_stat_activity data, there usually is only one other query executing: the select * from pg_stat_activity itself. Sometimes there's another query or a connection idle in transaction (which disappears again in the next output from pg_stat_activity), but given the volume of queries that's executed this seems expected. 2) Looking at pg_locks, the only locks that are consistently held throughout those 2 minutes are these 5: - the locks held by the slow query itself: an AccessShareLock on the job table, and a virtualxid ExclusiveLock (the query does not happen within a transaction). - the advisory lock for the job this thread is processing - locks held by the SELECT * FROM pg_locks query (a lock on the pg_locks table and a virtualxid lock) These 5 locks are of course all granted. Other locks change every 5 seconds, and often no other locks are held at all. Best regards, Roel -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance