Partitioning logic to treat temp tables as the real ones