PG 8.4.

I hope you realise that 8.4 goes out of support in 3 months. It's decidedly long in the tooth (to use another equine saying).

What I would do is use a recent postgres version (9.3.4 and even 9.4devel (which is almost in feature-freeze anyway)), fix any database problems on those, and then (if your app really needs it) work back to fix it on legacy versions (i.e.: 9.2.8, 9.1.13, 9.0.17). It's time to drop support for 8.4 (I see you even still mention 8.3 on your pages...).

And RichardK is right: get yourself acqainted with EXPLAIN ANALYZE output (at least to the point where you can tell whether an index is used, and useful).

if you can't get it sorted out with an index, I still think partitioning is the best way to solve your problem. I think all the talk of stored proceduring is a red herring.

IRC freenode #postgresql is often full of people who relish this kind of problem, even if it is somewhat FAQ-ish (sometimes you have to be patient).

Do let us know how you solve this. I'm interested. (If it wasn't 8.4 I'd probably have setup a little trial example...)

update: changed order of paragraphs: first try appropriate indexing, if that fails, partition).


In reply to Re^3: Help on selecting and deleting many records in a DB. by erix
in thread Help on selecting and deleting many records in a DB. by neilwatson

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.