Tom Lane wrote:
>
> Note that this isn't necessarily going to fix your performance problem,
> since a scan of the whole input table is still going to be required.
> But if the expensive processing was somewhere downstream of that basic
> scan, it should help.
>
The only way that I know of to do this fast is to insert the items in
random order. I've done this (in C++, not postgres) using a map
(b-tree) data structure: insert key-value pairs with the key being a
random number; then pop entries off the tail of the map as needed.
Tim
--
Timothy H. Keitt
National Center for Ecological Analysis and Synthesis
735 State Street, Suite 300, Santa Barbara, CA 93101
Phone: 805-892-2519, FAX: 805-892-2510
http://www.nceas.ucsb.edu/~keitt/