Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0309147700E; Fri, 4 Oct 2002 11:38:06 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 6F9D3477179; Fri, 4 Oct 2002 11:34:53 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 41433D60A; Fri, 4 Oct 2002 08:34:58 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 36EBA5C04; Fri, 4 Oct 2002 08:34:58 -0700 (PDT) Date: Fri, 4 Oct 2002 08:34:58 -0700 (PDT) From: Stephan Szabo To: Raymond Chui Cc: , , Subject: Re: [ADMIN] Fast Deletion For Large Tables In-Reply-To: <3D9B38F7.12A7AEA3@noaa.gov> Message-ID: <20021004083355.M36970-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/14 X-Sequence-Number: 779 On Wed, 2 Oct 2002, Raymond Chui wrote: > 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? Not really of that sort IIRC Oracle's row_id definition, although you could probably fake something with a sequence.