Check whether the number of AMPs are same in both of your TD versions. The spooling issue might happen with a single AMP running out of space if the table is not having proper Primary Index. Also check if the table you are using has grown more in the recent past. If nothing of them is true you have to only tune the query. You can probably create a volatile table to avoid this issue.