Using the TempTable and OutputTempTable tokens in raw SQL queries
When you use a raw SQL query in a Select process with an input cell, behavior in Campaign is different depending on whether in-DB optimization is enabled or disabled.
When in-DB optimization is disabled, the list of IDs from the raw SQL query is automatically matched against the ID list from the incoming cell so that the resulting list of IDs is a subset of the cell as expected. However, when in-DB optimization is enabled, Campaign expects the ID list generated from the Select process to be the final list, and does not automatically match this list against the ID list of any incoming cell. Therefore, when in-DB optimization is enabled, it is critical that the raw SQL query written for an intermediate Select process (in other words, a Select process with an input cell) uses the <TempTable> token to properly join against the incoming cell. Not only does this ensure correct results, joining against the input cell also improves performance by preventing extraneous processing for audience IDs that are not in the input cell.
*
In addition, using the <OutputTempTable> token maintains in-DB optimization and prevents the audience IDs from being retrieved from the database back to the Campaign server.
Example: Using the TempTable and OutputTempTable tokens