Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-29 Thread Gavin Flower
On 29/02/12 06:06, David Kerr wrote: On 02/27/2012 12:08 AM, Reuven M. Lerner wrote: Hi, everyone. I wanted to thank you again for your help on the huge delete problem that I was experiencing. After a lot of trial and error, we finally came to the conclusion that deleting this much data in the

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-29 Thread Lew
On 02/27/2012 07:14 AM, Shaun Thomas wrote: On 02/27/2012 08:59 AM, Reuven M. Lerner wrote: From what I understand, the issue isn't one of current disk space, but rather of how quickly the disk space is being used up. Noted. Just keep in mind that dead rows are not free. In the case of sequen

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-28 Thread David Kerr
On 02/27/2012 12:08 AM, Reuven M. Lerner wrote: Hi, everyone. I wanted to thank you again for your help on the huge delete problem that I was experiencing. After a lot of trial and error, we finally came to the conclusion that deleting this much data in the time frame that they need, on underpow

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-27 Thread Scott Marlowe
On Mon, Feb 27, 2012 at 2:13 PM, Samuel Gendler wrote: > > > On Mon, Feb 27, 2012 at 6:59 AM, Reuven M. Lerner > wrote: >> >> >> So for now, we'll just try to DELETE faster than we INSERT, and combined >> with autovacuum, I'm hoping that this crisis will be averted.  That said, >> the current sta

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-27 Thread Samuel Gendler
On Mon, Feb 27, 2012 at 6:59 AM, Reuven M. Lerner wrote: > > So for now, we'll just try to DELETE faster than we INSERT, and combined > with autovacuum, I'm hoping that this crisis will be averted. That said, > the current state of affairs with these machines is pretty fragile, and I > think that

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-27 Thread Claudio Freire
On Mon, Feb 27, 2012 at 12:01 PM, Shaun Thomas wrote: > > Like I said, this will stop his tables from growing further so long as he > keeps his maintenance functions running regularly from now on, but the > existing rows he's trying to delete will never go away until he runs a > CLUSTER or some ot

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-27 Thread Shaun Thomas
On 02/27/2012 08:59 AM, Reuven M. Lerner wrote: From what I understand, the issue isn't one of current disk space, but rather of how quickly the disk space is being used up. Noted. Just keep in mind that dead rows are not free. In the case of sequence scans, the rows still have to be read fro

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-27 Thread Shaun Thomas
On 02/27/2012 08:53 AM, Andrew Dunstan wrote: If he has autovacuum on he could well be just fine with his proposed strategy. Or he could have tables partitioned by time and do the delete by just dropping partitions. There are numerous way he could get this to work. He isn't using partitions th

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-27 Thread Reuven M. Lerner
Hi, Shaun. You wrote: In the end, it was agreed that we could execute the deletes over time, deleting items in the background, or in parallel with the application's work. After all, if the disk is filling up at the rate of 2 GB/day, then so long as we delete 4 GB/day (which is pretty easy to d

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-27 Thread Andrew Dunstan
On 02/27/2012 09:45 AM, Shaun Thomas wrote: On 02/27/2012 02:08 AM, Reuven M. Lerner wrote: In the end, it was agreed that we could execute the deletes over time, deleting items in the background, or in parallel with the application's work. After all, if the disk is filling up at the rate of

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-27 Thread Shaun Thomas
On 02/27/2012 02:08 AM, Reuven M. Lerner wrote: In the end, it was agreed that we could execute the deletes over time, deleting items in the background, or in parallel with the application's work. After all, if the disk is filling up at the rate of 2 GB/day, then so long as we delete 4 GB/day (w

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-27 Thread lephongvu
I have a question. Your data is growing 1Gb by 1 day. Can we use another Disk or partition to continue archive data ? I mean, do postgreSql support a Layering System for archive data ? -- View this message in context: http://postgresql.1045698.n5.nabble.com/Very-long-deletion-time-on-a-200-GB-d

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-27 Thread Reuven M. Lerner
Hi, everyone. I wanted to thank you again for your help on the huge delete problem that I was experiencing. After a lot of trial and error, we finally came to the conclusion that deleting this much data in the time frame that they need, on underpowered hardware that is shared with an applicat

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-26 Thread Reuven M. Lerner
Hi again, everyone. Wow, I can't get over how helpful everyone has been. Shaun wrote: The main problem you're going to run into is that your table is larger than the memory in that server. 4GB is really pretty small for a server hosting a 200+GB database. That they didn't mean it to get that

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-25 Thread Reuven M. Lerner
Hi, everyone. Jeff wrote: Is this 9 hours run time for deleting one day worth of data, or for deleting the entire accumulation of cruft that filled up the hard drive in the first place (which would be 170 days, if you have 200GB that accumulated at 1GB per day and you only need 30 days) ? Unf

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-25 Thread Jeff Janes
On Thu, Feb 23, 2012 at 12:39 AM, Reuven M. Lerner wrote: > Hi, everyone.  I'm maintaining an application that exists as a "black box" > in manufacturing plants.  The system is based on Windows, .NET, and > PostgreSQL 8.3.  I'm a Unix kind of guy myself, but the application layer > and system admi

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-24 Thread Steve Crawford
On 02/23/2012 12:39 AM, Reuven M. Lerner wrote: Hi, everyone. ... ...at one installation, we're quickly running out of disk space. The database is already taking up about 200 GB of space, and is growing by 1 GB or so a day. I've been following the discussion of approaches and tuning for bulk

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-24 Thread Shaun Thomas
On 02/24/2012 08:54 AM, Reuven M. Lerner wrote: I/O writes: process1: 820,000, process2: 1Milion Process3: 33,000 That's not especially helpful, unfortunately. That doesn't really tell us how saturated the controller is. However I suspect it's being effectively slammed based simply on your C

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-24 Thread Reuven M. Lerner
Hi, everyone. Shaun said: On 02/24/2012 12:39 AM, Reuven M. Lerner wrote: - CPU is virtually idle when running the deletes, using about 1% of CPU I think you found your problem. See if you can get the Windows admins to give you some info on how busy the disks are (percent utilization, IOPS,

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-24 Thread Shaun Thomas
On 02/24/2012 12:39 AM, Reuven M. Lerner wrote: - CPU is virtually idle when running the deletes, using about 1% of CPU I think you found your problem. See if you can get the Windows admins to give you some info on how busy the disks are (percent utilization, IOPS, something) the next time y

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-24 Thread Claudio Freire
On Fri, Feb 24, 2012 at 9:37 AM, Reuven M. Lerner wrote: > I just checked, and work_mem is set to 30 MB.  That seems a bit low to me, > given the size of the database and the fact that we're doing so much sorting > and subselecting.  Am I right that we should push that up some more? You can certa

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-24 Thread Reuven M. Lerner
Hi, everyone. Samuel wrote: What is work_mem set to? If all the other values were set so low, I'd expect work_mem to also be small, which could be causing all kind of disk activity when steps don't fit into a work_mem segment. I just checked, and work_mem is set to 30 MB. That seems a bit l

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-24 Thread Samuel Gendler
On Thu, Feb 23, 2012 at 10:39 PM, Reuven M. Lerner wrote: > Hi, everyone. > > So it turns out that we're not using 25 GB of virtual memory. (That's > what I had been shown yesterday, and it was a bit surprising, to say the > least...) > > A few statistics that I managed to get from the Windows de

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-24 Thread Lew
On 02/23/2012 07:28 AM, k...@rice.edu wrote: On Thu, Feb 23, 2012 at 05:25:46PM +0200, Reuven M. Lerner wrote: What is the distribution of end_dates? It might be worth running this in several steps, deleting records older than, say, 90 days, 60 days, 30 days. I've suggested something similar,

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-23 Thread Reuven M. Lerner
Hi, everyone. So it turns out that we're not using 25 GB of virtual memory. (That's what I had been shown yesterday, and it was a bit surprising, to say the least...) A few statistics that I managed to get from the Windows developers/system administrators: - The machine has a total of 3.5

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-23 Thread Jesper Krogh
On 23/02/12 09:39, Reuven M. Lerner wrote: Hi, everyone. I'm maintaining an application that exists as a "black box" in manufacturing plants. The system is based on Windows, .NET, and PostgreSQL 8.3. I'm a Unix kind of guy myself, but the application layer and system administration are being

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-23 Thread Tom Lane
I just reread the original post and noted this: "Reuven M. Lerner" writes: > (1) I tried to write this as a join, rather than a subselect. But B has > an oid column that points to large objects, and on which we have a rule > that removes the associated large object when a row in B is removed.

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-23 Thread Tom Lane
Greg Spiegelberg writes: > I used LOCK simply because if a VACUUM FULL x; slipped in between the > SELECT and the DELETE the ctid's could conceivably change. VACUUM FULL can't "slip in" there, because you'd have AccessShareLock just from the SELECT. The real problem goes like this: 1. Y

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-23 Thread Greg Spiegelberg
On Thu, Feb 23, 2012 at 11:11 AM, Andy Colson wrote: > On 2/23/2012 12:05 PM, Shaun Thomas wrote: > >> On 02/23/2012 11:56 AM, Greg Spiegelberg wrote: >> >> I know there are perils in using ctid but with the LOCK it should be >>> safe. This transaction took perhaps 30 minutes and removed 100k ro

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-23 Thread Andy Colson
On 2/23/2012 12:05 PM, Shaun Thomas wrote: On 02/23/2012 11:56 AM, Greg Spiegelberg wrote: I know there are perils in using ctid but with the LOCK it should be safe. This transaction took perhaps 30 minutes and removed 100k rows and once the table was VACUUM'd afterward it freed up close to 20

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-23 Thread Shaun Thomas
On 02/23/2012 11:56 AM, Greg Spiegelberg wrote: I know there are perils in using ctid but with the LOCK it should be safe. This transaction took perhaps 30 minutes and removed 100k rows and once the table was VACUUM'd afterward it freed up close to 20 GB on the file system. It took *30 minutes

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-23 Thread Greg Spiegelberg
On Thu, Feb 23, 2012 at 8:25 AM, Reuven M. Lerner wrote: > > I've suggested something similar, but was told that we have limited time > to execute the DELETE, and that doing it in stages might not be possible. > > Just so happens I had this exact problem last week on a rather large table. * DELET

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-23 Thread Shaun Thomas
On 02/23/2012 02:39 AM, Reuven M. Lerner wrote: I should note that my primary concern is available RAM. The database, as I wrote, is about 200 GB in size, and PostgreSQL is reporting (according to Windows) use of about 5 GB RAM, plus another 25 GB of virtual memory. O_o That... that would pro

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-23 Thread Steve Crawford
On 02/23/2012 12:39 AM, Reuven M. Lerner wrote: Hi, everyone... This is basically what I'm trying to execute: DELETE FROM B WHERE r_id IN (SELECT R.id FROM R, B WHERE r.end_date < (NOW() - (interval '1 day' * 30)) AND r.id = b.r_id I don't recall which versions like which appro

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-23 Thread k...@rice.edu
On Thu, Feb 23, 2012 at 05:25:46PM +0200, Reuven M. Lerner wrote: > > > >What is the distribution of end_dates? It might be worth running this in > >several steps, deleting records older than, say, 90 days, 60 days, 30 days. > > I've suggested something similar, but was told that we have limited >

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-23 Thread Reuven M. Lerner
Hi, everyone. Thanks for all of the help and suggestions so far; I'll try to respond to some of them soon. Andrew wrote: How about: DELETE FROM B WHERE r_id IN (SELECT distinct R.id FROM R WHERE r.end_date< (NOW() - (interval '1 day' * 30)) ? Or possibly without the DISTINCT. But I agree

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-23 Thread Andrew Dunstan
On 02/23/2012 05:07 AM, Marcin Mańk wrote: DELETE FROM B WHERE r_id IN (SELECT R.id FROM R, B WHERE r.end_date< (NOW() - (interval '1 day' * 30)) AND r.id = b.r_id How about: DELETE FROM B WHERE r_id IN (SELECT distinct R.id FROM R WHERE r.end_date< (NOW() - (in

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-23 Thread Claudio Freire
On Thu, Feb 23, 2012 at 5:39 AM, Reuven M. Lerner wrote: > Unfortunately, when we implemented this simple delete, it executed slower > than molasses, taking about 9 hours to do its thing.   Not only does this > seem like a really, really long time to do such deleting, but we have only a > 4-hour w

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-23 Thread Richard Huxton
On 23/02/12 08:39, Reuven M. Lerner wrote: (4) I tried "chunking" the deletes, such that instead of trying to delete all of the records from the B table, I would instead delete just those associated with 100 or 200 rows from the R table. On a 1 GB subset of the data, this seemed to work just f

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-23 Thread Marcin Mańk
> DELETE FROM  B > WHERE r_id IN (SELECT R.id >     FROM R, B >    WHERE r.end_date < (NOW() - (interval '1 day' * 30)) >      AND r.id = b.r_id > How about: DELETE FROM  B WHERE r_id IN (SELECT distinct R.id     FROM R  WHERE r.end_date < (NOW() - (interval '1 day' * 30)) ? Greetings Marcin

Re: [PERFORM] Very long deletion time on a 200 GB database

2012-02-23 Thread Glyn Astill
Do you have any more detailed information about the hardware, what sort of disk configuration does it have? Can you get onto the machine to look at what is using those resources?  You mention the 25gb of virtual memory; is that being used?  If so is it being used by postgres or something else?