Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oPpg3-0005nT-Jk for pgsql-admin@arkaria.postgresql.org; Sun, 21 Aug 2022 18:28:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oPpg1-0007Hm-NN for pgsql-admin@arkaria.postgresql.org; Sun, 21 Aug 2022 18:28:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oPpg1-0007Hd-BQ for pgsql-admin@lists.postgresql.org; Sun, 21 Aug 2022 18:28:01 +0000 Received: from mail-qt1-x831.google.com ([2607:f8b0:4864:20::831]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oPpfu-0006Ec-UI for pgsql-admin@lists.postgresql.org; Sun, 21 Aug 2022 18:28:00 +0000 Received: by mail-qt1-x831.google.com with SMTP id cr9so6518471qtb.13 for ; Sun, 21 Aug 2022 11:27:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc; bh=NReP4nXNxjmYu65dvA9lPLgcuwf6JUCmIVZd3uufiRo=; b=k8zmzGgD3a5uI5aO2CZmMeoE2NgQfUl3z9pGlItswScEzCBVZqd2clOvglx6F6M+bI SFlBZE2XZQ1p+MKuw+qAHIQpI7MTUlkkZDVoDjk7p348VR7ccOf52kMV/7BGLSNjwBIL ADfVGIjZCYPqo2Lj7JsE/dg/TvaUyVOnrPPQ1UH6AHx+2etjY/hem7B/7ON6xQZWT0DG 0x/G0+GLMC6VBq9g34MMMd0/TNKrkUcpSTKZznNMn5LFIJI1moc9K/q7y4D3dxFLmiD0 VSA3JSblWn6VBQA5/rqAw+cT4Jbp4Y8DF7BYWaFTz+NQn6QR3Cb0F5phrwjvgk+Xn/6/ txEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc; bh=NReP4nXNxjmYu65dvA9lPLgcuwf6JUCmIVZd3uufiRo=; b=OX0SWgZR+E9F7eeQsg4WJ8Im9Tt9zwDlHnPV6iT6PxPpTrkIDHTm6mcja52MeC83vk wSHScslWmnh8wyJJQ7Glputm9Qq9saIeCga+fUGRbJahUccQRfEQRtmehXOw08X4w2PZ XzAqagC1bLnaq9qG8/uwhyJ0jmtu4WU3Ep7kEzCD/1dXsuVzRv3pSifPIvXip8xiKzVk cUXuAefXIDtKG08pW2jKe/z23Ea0RsBcNnXp/ZW29U8vPu6GTgBcNsdd9xKVM7x6NgmN qXQS2H9AsI83sUxrMsNODRcR2ppIVpOhi9Qqh9KfgNB+q1rvOdJVFTufotzzmedZcW6q sinw== X-Gm-Message-State: ACgBeo3befNA7Kr4LaNsAipaafmSRfQe9Ksh83lcoynvUjyk80r8HH8j 91+r9prHW0MrUZsvomlTTfbWEzm/MDdAYKHZ X-Google-Smtp-Source: AA6agR5DqcDuGFC1iQBYBG1kso/2kBLmy1sUcdIfPceLIfSQdgRXiSm5T73gdrVaRvq+OoUqM8Wg9Q== X-Received: by 2002:ac8:5bcd:0:b0:343:7d45:ee05 with SMTP id b13-20020ac85bcd000000b003437d45ee05mr13062199qtb.653.1661106472170; Sun, 21 Aug 2022 11:27:52 -0700 (PDT) Received: from [192.168.2.100] (pool-72-79-30-4.nwrknj.east.verizon.net. [72.79.30.4]) by smtp.gmail.com with ESMTPSA id g18-20020a05620a40d200b006bb9e4b96e6sm9344088qko.24.2022.08.21.11.27.51 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 21 Aug 2022 11:27:51 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------188NfgTp2HgTsaNCrU0hZ1qL" Message-ID: <62c9a8d8-8c0f-3c11-5cca-e05e126c25d8@gmail.com> Date: Sun, 21 Aug 2022 14:27:50 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: Postgresql 14 performance Content-Language: en-US To: pgsql-admin@lists.postgresql.org References: From: Mladen Gogala In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------188NfgTp2HgTsaNCrU0hZ1qL Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 8/21/22 12:05, Kenny Bachman wrote: > Hi Team, > > Have a lovely Sunday. > I have a problem with PostgreSQL performance. I am using PostgreSQL > 14.5 on Linux physical server. My query was taking 1 or 2 seconds > yesterday, but today it is taking 5-6 seconds. Also, nothing has > changed in the database. Also, when I run the query for the second > time, the query runs for the same time, so I expect it to be more > performant the second time because of the cache. > (the database cache hit ratio is 97,8) > > Lastly, some other queries take milliseconds normally, but sometimes > they take minutes. I didn't understand why this is happening. (There > is no lock, no table bloating and up to date analyze) > > > I am adding the explain analyze output as an attachment. Hi Kenny, The query is small but the plan is huge and likely to use a lot of memory. What is with the rest of the system? Any paging? There are lots of steps that are never executed in the plan. The plan looks great, mostly unique index equality scans. Did you check pg_stat_activity for wait_event_type and wait_event? What is your SQL waiting for? Regards -- Mladen Gogala Database Consultant Tel: (347) 321-1217 https://dbwhisperer.wordpress.com --------------188NfgTp2HgTsaNCrU0hZ1qL Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 8/21/22 12:05, Kenny Bachman wrote:
Hi Team,

Have a lovely Sunday. 
I have a problem with PostgreSQL performance. I am using PostgreSQL 14.5 on Linux physical server. My query was taking 1 or 2 seconds yesterday, but today it is taking 5-6 seconds. Also, nothing has changed in the database. Also, when I run the query for the second time, the query runs for the same time, so I expect it to be more performant the second time because of the cache.
(the database cache hit ratio is 97,8)

Lastly, some other queries take milliseconds normally, but sometimes they take minutes. I didn't understand why this is happening. (There is no lock, no table bloating and up to date analyze)


I am adding the explain analyze output as an attachment.

Hi Kenny,

The query is small but the plan is huge and likely to use a lot of memory. What is with the rest of the system? Any paging? There are lots of steps that are never executed in the plan. The plan looks great, mostly unique index equality scans. Did you check pg_stat_activity for wait_event_type and wait_event? What is your SQL waiting for?

Regards

-- 
Mladen Gogala
Database Consultant
Tel: (347) 321-1217
https://dbwhisperer.wordpress.com
--------------188NfgTp2HgTsaNCrU0hZ1qL--