Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id ADEA14760AA; Wed, 2 Oct 2002 14:20:41 -0400 (EDT) Received: from ssmcmail.nems.noaa.gov (ssmcmail.nems.noaa.gov [205.156.4.221]) by postgresql.org (Postfix) with ESMTP id C9ADF475F64; Wed, 2 Oct 2002 14:20:40 -0400 (EDT) Received: from noaa.gov ([140.90.8.96]) by ssmcmail.nems.noaa.gov (Netscape Messaging Server 4.15) with ESMTP id H3D9MH00.GNW; Wed, 2 Oct 2002 14:20:41 -0400 Message-ID: <3D9B38F7.12A7AEA3@noaa.gov> Date: Wed, 02 Oct 2002 14:20:39 -0400 From: Raymond Chui Organization: NWS NOAA X-Mailer: Mozilla 4.75 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-admin@postgresql.org, pgadmin-support@postgresql.org, pgsql-general@postgresql.org Subject: Fast Deletion For Large Tables Content-Type: multipart/mixed; boundary="------------DADECDA67CFCBF70F75363F7" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/6 X-Sequence-Number: 771 This is a multi-part message in MIME format. --------------DADECDA67CFCBF70F75363F7 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I have some tables with huge data. The tables have column timestamp and float. I am try to keep up to 6 day of data values. What I do is execute SQL below from crontab (UNIX to schedule commands). BEGIN; DELETE FROM table_1 WHERE column_time < ('now'::timestamp - '6 days'::interval); ..... DELETE FROM table_n WHERE column_time < ('now'::timestamp - '6 days'::interval); COMMIT; Everything is running fine, except take long time to finish. Because some tables stored values from 50,000 to 100,000 rows Some deletion need to deleted up to 45,000 rows. So I am thinking just delete the rows by their row number or row ID, like DELETE FROM a_table WHERE row_id < 45000; I know there is row_id in Oracle. Is there row_id for a table in Postgres? Thank Q! --------------DADECDA67CFCBF70F75363F7 Content-Type: text/x-vcard; charset=us-ascii; name="raymond.chui.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Raymond Chui Content-Disposition: attachment; filename="raymond.chui.vcf" begin:vcard n:Chui;Raymond tel;work:301-713-0640 x168 x-mozilla-html:FALSE url:http://www.nws.noaa.gov/ org:NWS, NOAA;OHD13 version:2.1 email;internet:raymond.chui@noaa.gov title:CS adr;quoted-printable:;;1325 East-West Highway=0D=0ASSMC2, Room 8112;Silver Spring;MD;20910-3282;U.S.A. fn:Raymond Chui end:vcard --------------DADECDA67CFCBF70F75363F7--