Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1go8en-0005ne-F8 for pgsql-general@arkaria.postgresql.org; Mon, 28 Jan 2019 15:17:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1go8el-0006L7-NV for pgsql-general@arkaria.postgresql.org; Mon, 28 Jan 2019 15:17:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1go8el-0006L0-Er for pgsql-general@lists.postgresql.org; Mon, 28 Jan 2019 15:17:03 +0000 Received: from [66.111.4.29] (helo=out5-smtp.messagingengine.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1go8ej-0006QG-3P for pgsql-general@lists.postgresql.org; Mon, 28 Jan 2019 15:17:03 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 5C646221BC; Mon, 28 Jan 2019 10:16:39 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 28 Jan 2019 10:16:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=F E8vJbROSvpCP3ysImsuvTAxk3OLF3k3YqgMVMJGWO0=; b=wQVvIUAv8v6TI3ICT m6TCzP3T5vqmfGsYrxHEXLXIHMMOl3QgqMlQ87gk5R5qX128t+1eOEM6jXfstdQA QFHw2vUun4NKtYDa6EDRiL4Lg6MIVD64Jtgm9B2mdNYOXC2ehFGK3pb0NO0fCyuH ICpG/Sgq2bNfUBLPOgOGHinHq0jdemkpe3XSkGn+nA5jBhCgRmQNordqooupExhS 5EY9ZjiBqdweg+x19P+9LCDVMvvt37UGQIsrdTjSSUNwC8qohaW6WYU5S/4mzSLc SBhARqK8WbF708ozmNnYXbrKO4JMYJHBcqaNbsCO/tuAuKly3vQ0V9diVXUH6ZAW fiogg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=FE8vJbROSvpCP3ysImsuvTAxk3OLF3k3YqgMVMJGW O0=; b=OdCjiamIMKRRzUA4Mk1Ozf5m94oUNGBjJwMu14fPirjs778fDjtN8waOa LmskwH8EZ12lDai6cS9X5Zx1AiFTPL++yPM8F3+W5nPmz5/sbVDFuhUT8sI9BYe/ 4kfe/92V0hKFiiKYBS+PYaVoVp+QsWlK7hCX9tLIKo/a1M/FO1PyoB1gMb5E1E8+ ijWGy9M4sXkb/m7WuLeiWj6GaU4l/vyaEVQpo7ZvYHn/ZJxQG/q+TOSPTNXYfySa vO/PsN7wtRiFFGuiwqqBcjktxUD+gdcAVPLbSCGXEVjEp6YgseVteOobzCqlcRow /QoKu7UOfO40PsTENNt4QdcEqV4sA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrjedtgdejkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecufedt tdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepuffvfhfhkffffg ggjggtgfesthekredttdefjeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegr ughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmqeenucffohhmrghinhepph hoshhtghhrvghsqhhlrdhorhhgnecukfhppeejuddrvdduvddrudefgedrfeenucfrrghr rghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from [192.168.1.2] (unknown [71.212.134.3]) by mail.messagingengine.com (Postfix) with ESMTPA id 0C8BD10312; Mon, 28 Jan 2019 10:16:37 -0500 (EST) Subject: Re: Regarding query execution for long time To: Durgamahesh Manne , pgsql-general@lists.postgresql.org Cc: Andreas Kretschmer References: From: Adrian Klaver Message-ID: Date: Mon, 28 Jan 2019 07:16:37 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 66.111.4.29 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/28/19 4:20 AM, Durgamahesh Manne wrote: > Hi > > below query is being executed for long time > > Select > distinct ltrim(rtrim(ssnumber)), CL.iInsightClientId, > ltrim(rtrim(TFA.client_account_key)) as vchAccountNumber, > concat(TFA.first_name, ' ', TFA.last_name) as vchAccountName, > concat('AP:TIAA', TFA.routing_number) as vchRepLabel, > null as vchOpenDate, TFA.address1 as vchAccountTiteLine2, > TFA.address2 as vchAccountTitleLine3,null as vchAccountType, > TFA.address1 as vchPrimaryContact, 'TIAA-CREF' as Custodian, > TFA.routing_number as vchCustodian_RepId, null as vchCustodianRepName, > CONCAT ('TIAA-CREF:',ltrim(rtrim(client_account_key)),':', > ltrim(rtrim(ssnumber))) as vchAccountKey, > null as vchFeedsAccountType > from accounts as TFA > join client3 as CL on > ltrim(rtrim(Cl.vchssnumber))=ltrim(rtrim(TFA.ssnumber)) > left join account3 as AC on > ltrim(rtrim(AC."vchCustodianAccountNumber"))=ltrim(rtrim(TFA.client_account_key)) > where AC."iInsightAccountID" is null; > >  query is being executed for long time even after i have created > required indexes on columns of the tables > please help for fast query execution See below for information on how to report these sort of issues: https://wiki.postgresql.org/wiki/SlowQueryQuestions > > Regards > durgamahesh manne > -- Adrian Klaver adrian.klaver@aklaver.com