Of course, that's not legal 7.3.4 syntax.  These are both too
slow due to sequential scan of table:

        delete from mytable where key in (
                select key
                from mytable
                where posteddatetime < now() - '90 days'
                limit 100);

Upgrade to 7.4 - the query above will be vastly faster.


        delete from mytable where exists (
                select m.key
                from mytable m
                where m.key = mytable.key
                  and m.posteddatetime < now() - '90 days'
                limit 100);

That one I used to use on 7.3 - I seem to recall it indexed nicely.


Chris

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Reply via email to