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 1nZocw-0003BM-Uy for pgsql-performance@arkaria.postgresql.org; Thu, 31 Mar 2022 06:49:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nZocu-0006Fx-7G for pgsql-performance@arkaria.postgresql.org; Thu, 31 Mar 2022 06:49:48 +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 1nZoct-0006Fo-PZ for pgsql-performance@lists.postgresql.org; Thu, 31 Mar 2022 06:49:47 +0000 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nZocr-0001se-DO for pgsql-performance@lists.postgresql.org; Thu, 31 Mar 2022 06:49:47 +0000 Received: by mail-io1-xd34.google.com with SMTP id g21so14341996iom.13 for ; Wed, 30 Mar 2022 23:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=RdkcErJdk/aDZUfjgPE/jwEzvXjIJkev165mSMZsJcY=; b=R84WaTomtlUts352Qbh+w+kjGqvMqzDiJLrWsYt2ACQTHfLmEMLpoOhOk2aQRNqAEt f2d3CHJSbdFeC48CvHwE7yBw3A2w9vmfZSxWmyP5SnNrs7t/YxiBhrMmXXe9FCu+GUnE uOmU5/QOOADyJ2h+kHgOf3QmcwJOrhASZSkbHX81BkNeTMhn9t5sYnAL/Ym5/J99sX8r 7tdu9S1hG4vcgsuvv3Ch2mYvDOF+rozWW4KBksY+KzGMpfHpchuqlOqlBKipeNJSdSII 4sUTPJehSNIRbZIkgFt5YXwAsEid6gLuLGsun2fMl8rfFlVvumhd7zmhVku8nD/rlw9e xZCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=RdkcErJdk/aDZUfjgPE/jwEzvXjIJkev165mSMZsJcY=; b=bRd5RQvzTLrF0vlz8PUwjZ/4Wh6NLmIp5nX0zoxq2z0K2CTG3KDEL6eA/wjqaZbDut G0tb8IjQjWqutEKFFq+BwVHsvkrIwnYy8SIg1Vb4lhGiwOZEnUvNBKxDyUBCWlces1xz INrtb4Jjx1sCbt++EaGtnaHaZT07nba2QjM4sa1oDmNLdkZjuMO+k9x7BfNenRx5zCXw lC4PIqzzuhfFoSinBzmZ10usf2//fAl3opIj3librcXL3tHxVu583eKtFutUvGMnkYGv g7Xf1iUbdW3YIFuQxg1vmhdjVEPAI8SZQpxcRPD8L2aGfzSL+EA+eMliyOijQfSrQUnR QOeA== X-Gm-Message-State: AOAM53212PJgh/y+RrNHONEdP4bALU7l4HUrquQCWx7QuPng1kmrZFjr 3Sps33vlBRDMtv3kDdS78C9TFA== X-Google-Smtp-Source: ABdhPJxxWUfhxMCHvSP1kRIzzFHAs3d03bIRyw+otIWTINgb2AfdD3tFxaBqQFcaWUdjUbUdFHfhOA== X-Received: by 2002:a05:6638:4197:b0:321:4854:b5e2 with SMTP id az23-20020a056638419700b003214854b5e2mr2345531jab.272.1648709384106; Wed, 30 Mar 2022 23:49:44 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id d16-20020a05660225d000b00645c8db7767sm12624403iop.35.2022.03.30.23.49.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Mar 2022 23:49:43 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id E49108019CF; Thu, 31 Mar 2022 01:49:41 -0500 (CDT) Date: Thu, 31 Mar 2022 01:49:41 -0500 From: Justin Pryzby To: Rambabu g Cc: pgsql-performance@lists.postgresql.org Subject: Re: HIGH IO and Less CPU utilization Message-ID: <20220331064941.GM28503@telsasoft.com> References: <20220329182453.GA28503@telsasoft.com> <20220329193941.GB28503@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Mar 30, 2022 at 10:17:38AM +0530, Rambabu g wrote: > Hi Justin, > > Only one query is causing the issue, sharing the def of indexes. Please > have a look. > > > > There are three indexes defined on the table, each one is around 20 to 25GB > > tp | character varying(2000) | yes | tp | extended | > > 852 | 00:09:56.131136 | IO | DataFileRead | explain > analyze select distinct empno from emp where sname='test' and tp='EMP > NAME 1' The server is doing a scan of the large table. The tp index matches a lot of rows (13e6) which probably aren't clustered, so it elects to scan the 500GB table each time. Looking at this in isolation, maybe it'd be enough to create an index on tp,empno (and maybe drop the tp index). CREATE INDEX CONCURRENTLY if you don't want to disrupt other queries. But This seems like something that should be solved in a better way though ; like keeping a table with all the necessary "empno" maintained with "INSERT ON CONFLICT DO NOTHING". Or a trigger.