in reply to Help on selecting and deleting many records in a DB.

Some thoughts :

1. Is it possible to build an index on the columns that comprise the group by ? make it a Hash one since you work on exact equality matches, thus the delete will operate a lot faster.

2. Try using NOT EXISTS (although they are not the same semantically, but in most cases they do match)

3. Having a function, DATE_TRUNC, inside the group by slows the query a lot. Turn on the query optimizer to check if that it is true.

  • Comment on Re: Help on selecting and deleting many records in a DB.