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 1oE54q-0000Rv-UJ for pgsql-general@arkaria.postgresql.org; Wed, 20 Jul 2022 08:29:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oE54o-0001Yz-Tr for pgsql-general@arkaria.postgresql.org; Wed, 20 Jul 2022 08:29:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oE54o-0001Wl-Jj for pgsql-general@lists.postgresql.org; Wed, 20 Jul 2022 08:29:02 +0000 Received: from mail-oa1-x35.google.com ([2001:4860:4864:20::35]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oE54i-0003wP-Bt for pgsql-general@lists.postgresql.org; Wed, 20 Jul 2022 08:29:01 +0000 Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-10bd4812c29so35185364fac.11 for ; Wed, 20 Jul 2022 01:28:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=sB8TlZDbJbAAh6Jv0HYmD2zytYlhRoQuucVLRHtAqnQ=; b=GZd1siU3sHP/qe6WroRIMrHQkN28RpBax6A3amVukyBR6rJ2RE4v0A0qcufjaqKqql tHmaSdgifVvk2Tf9UDQAHbwzayZN/f2EA+7jeTuZjUFp0WgjQ1yZbAWfE6qKsK0ewDJW XK7zAScUvj0d+sgyCbq4OKSjQWhJIPjmsJzJlWMbesbFdemd3x+iFsQDAroGObDgayYa uSlQwO2bZgRIttLS3nTYkIvg3jCnLOXUdWmDaNvQvcy6VHYfpdQUh5QFVeLl4lNuNY3L zrnxp9uE6yGQjLkAXso9UxS4JDclV5vBZ1E+P00eW6/2859eUgOAgtIxp0vH85641by1 yeHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=sB8TlZDbJbAAh6Jv0HYmD2zytYlhRoQuucVLRHtAqnQ=; b=LlETHg0y/iVrZwGTZQw5OgvlRqVbmYHyLoc1iFDEV/7NOTIAU5eKXclaRDpARTjUzW PAMtfH1skQIm+Bbv4buCrC6RNlgM6+DrjldnNj6Zche9m0cmqXYawZ1R4jr4hj1vfXtC YzZwWGVn85RadjPbqdykWmCTsw2JW+5ywP1fYrEiQ1FQWLMsfeM7XFrNbynz3W91/14a lzd3rRr73lsNsEjn/YhwSPI5btedwd1j8Q0+ayEWkNo7zGmJ1Csk8j/SCfPw/qK9TBUv JsOh8MoME/uS4CK6dVsJw85MXtNRKvO/yNz2zVImKFJtNcwTq1qVoRERDYW7a0kuBRVm 1hDQ== X-Gm-Message-State: AJIora/cV7htbU5pqUjHIPKcLJkDbFg4ECXPukBOM+zWnfH7pmjfMSgN UKClyfze1hL1Yl61OIcPE5pZ/vj3fr0= X-Google-Smtp-Source: AGRyM1urtGD5uCWDLKQwSRbaLUxpmA5lRXEORgdHa5uB+zfv8QQGdOCGO2O/dNdXsEwxx+1haSZQUQ== X-Received: by 2002:a05:6870:c898:b0:10c:6254:a543 with SMTP id er24-20020a056870c89800b0010c6254a543mr1827172oab.103.1658305735567; Wed, 20 Jul 2022 01:28:55 -0700 (PDT) Received: from [192.168.88.10] (ip68-11-68-85.no.no.cox.net. [68.11.68.85]) by smtp.googlemail.com with ESMTPSA id l8-20020a4ab2c8000000b0035eb4e5a6cbsm6888956ooo.33.2022.07.20.01.28.54 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Jul 2022 01:28:55 -0700 (PDT) Message-ID: <5d0d0349-1e6f-3f8f-41cb-3d853712eff9@gmail.com> Date: Wed, 20 Jul 2022 03:28:54 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: Batch process Content-Language: en-US To: pgsql-general@lists.postgresql.org References: From: Ron In-Reply-To: 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 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