Re: how to delete many rows from a huge table?
От | Scott Marlowe |
---|---|
Тема | Re: how to delete many rows from a huge table? |
Дата | |
Msg-id | dcc563d10905252245r1c00c032s3149909795098a86@mail.gmail.com обсуждение исходный текст |
Ответ на | how to delete many rows from a huge table? (mARK bLOORE <mbloore@gmail.com>) |
Список | pgsql-general |
On Mon, May 25, 2009 at 1:29 PM, mARK bLOORE <mbloore@gmail.com> wrote: > The table listing what I want to delete has just the key values. > > If I just do > > DELETE FROM backlinks b USING bad_links bl WHERE b.key = bl.key; > > then it grinds for an hour or so and runs out of memory. > > If I do > > DELETE FROM backlinks b WHERE b.key IN (SELECT bl.key FROM bad_links > bl LIMIT 40 OFFSET 0); > > it finishes in milliseconds, but if I set the LIMIT to 50, it runs for > minutes til I kill it. EXPLAIN says that it is doing a sequential > scan on several of the partitions in the 50 case, but not the 40. > Auto-vacuuming is running on the DB. > > If I put that DELETE into a procedure and loop on the offset, it acts > like the 50 case, even if i set the LIMIT to 1. What does explain of those three queries show you? I'm guessing that cranking up work_mem may help.
В списке pgsql-general по дате отправления: