That work_mem value could be way too high depending on how much ram yourserver has...which would be a very important bit of information to helpfigure this out. Also, what Postgres / OS versions?