Are you using proper temporary tables for this?