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 1oEB4B-0007sn-Qh for pgsql-general@arkaria.postgresql.org; Wed, 20 Jul 2022 14:52:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oEB4A-0005Y0-Mc for pgsql-general@arkaria.postgresql.org; Wed, 20 Jul 2022 14:52:46 +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 1oEB49-0005N0-2H for pgsql-general@lists.postgresql.org; Wed, 20 Jul 2022 14:52:46 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oEB45-0006Eb-5S for pgsql-general@lists.postgresql.org; Wed, 20 Jul 2022 14:52:44 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 6E3BC32006F2; Wed, 20 Jul 2022 10:52:37 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 20 Jul 2022 10:52:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1658328756; x= 1658415156; bh=aKveNTW0tv//4qR/Ayd9zTn9JbLUTWw7T/E5q0EdhJ4=; b=t lE7Tq/XKWM0G9DZ4ZynvxJS8Odr443575gbb3FWaKZqQbkoHpyH9swCbFDXEytge fQsF1wqqq4TihfHnd8skxnf6ZLXAL94O0MHJcAGboV34TiaeZNzXQ3A1nb28RMmW iJujJRQn1qwTp8pCGTY9trFBHuAFXdLwgWiQrY7iK2b1/GXb2YmBhRLfQrUxp0La O6SQX4lXFsISQGj7lSfp1NARMvZKVqGZmFehGASuUqsLLengbSCLSZDJs3vrAi1K tOJ+/vLMCHnNmR2R2jVi0sRjN+6hW1vy2rYrKZbus3Hccj+Gz9eJUiLvjQ0Ndy8c BrlfPy9lyQjMxWtY15ajg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1658328756; x=1658415156; bh=a KveNTW0tv//4qR/Ayd9zTn9JbLUTWw7T/E5q0EdhJ4=; b=NIkFp5F9N6ledAAAa v+kceciLwebv6ac4sadFLOHezR4Jh9mKxPRnBPedlP88S3hXhD21uS0ulMyzq3Ic +JkMAi7NBQGmbmL5NTHHqnIx5Otw4ZDnZC17YkXWw0R/pynb+uLMh8GcsbS/+3h3 cjqzor7aecx2uPUqj33doYLs3S74O7BPudWzc8ZC3Z58HtAmELCsJH9Od5Tevssa /2vn+Mdhl852OdD1hAbIHyje616meFZf88eM3dwiPSquObEW8gS+6SFEgZSuRTXu gdvLJka5q8Cn2FetrLqJXxdoBO2nYbZZA/W1rwzVbjWS0t4+Ua9B44mvPWMvBf2v bZ93g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudelvddgkeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtke ertddtfeejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhk lhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhepudfgueelge evfffhgeeljeehhfettdegieelgefgheefffefveegjedtueetffdtnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvh gvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 20 Jul 2022 10:52:36 -0400 (EDT) Message-ID: Date: Wed, 20 Jul 2022 07:52:35 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: Batch process Content-Language: en-US To: Ron , pgsql-general@lists.postgresql.org References: <5d0d0349-1e6f-3f8f-41cb-3d853712eff9@gmail.com> From: Adrian Klaver In-Reply-To: <5d0d0349-1e6f-3f8f-41cb-3d853712eff9@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 7/20/22 01:28, Ron wrote: > On 7/20/22 00:08, Rama Krishnan wrote: >> Hi All, >> >> I am doing purge activity my sales table contains 5M records I am >> going to delete more than 1 year data (which was 3M) records so it was >> running more so I want to do batch wise deletion through plsql >> >> >> >> >>  created or replace function data_purge() returns void as$$ >> Declare >> Begin >> Drop table test_old; >> Create table test_old as select * from sales where bill_date> -interval '1 year'; >> >> Delete table sales where sales_id in (select sales_id from test_old; >> >> End; >> $$ language plpgsql; >> >> >> Kindly guide me > > Why not just DELETE FROM sales WHERE bill_date Because it looks like the OP is saving the old records in test_old. -- Adrian Klaver adrian.klaver@aklaver.com