> There was an
> attempt to fix it (for example so that it could try to do a
> seqscan+sort
> instead of indexscan), but it stalled.
Actually I read that, but it's complicated... it involves planning and a lot of other stuff I don't even know about...
My "solution" I guess would be easier (but, of course, can't be used if you don't have enough work_mem):
if heap table <= work_mem
copy heap table in mem
use that region as it was the real file
else
do the regular (slow!) cluster
I guess this can be worse than the current way of doing it only when the table contains a lot of dead rows; in all
othercases I can't see how cluster could ever become faster than a simple table + index scans.
Of course, I'm not saying it's "very easy" to implement... but given the tons of ram a lot of people use in the
servers,and the fact that work_mem can be set on a per-connection basis, I think it would be nice...