Query Activities
Query Activities are the backend mechanism of the Run phase. Whenever you click the Run button in Unaric Segment, standard SFMC Query Activities are automatically created and executed via the API. These can be use them wherever you would normally use any other Query Activity, such as in Automation Studio or Journey Builder.
Query Activities storage location
Query Activities are created and saved at Automation Studio > Activities > SQL Query > All SQL Query > Query > DESelect. You'll see two subfolders:
- System:Tthis folder contains all query activities generated by Unaric Segment to create previews and count the number of results in a selection. Do not delete this folder or modify/delete the query activities in it.
- Selections: This folder contains the query activities created when a user clicks the Run button on a Selection in Unaric Segment. The names of the query activities match with the name of the selection, followed with a unique number. You can freely move the SQL Query Activities from the Selections folder to any other query activities folder.
Query Activities and deduplication
When you use deduplication in a Selection, an additional Query Activity is created and run after the initial one. This one will have the same name as the Selection, followed by -dedup and a random number. For example, if you have a selection called Halloween Promotion 2020, your Query Activity will be 2020 Halloween Promotion 1600333453317. If you use deduplication, you'll find an additional Query Activity called Halloween Promotion 2020-Dedup 1600333453317.
You can use these Query Activities inside an Automation or in Journey Builder. In case you are using deduplication, do not forget to add both generated Query Activities inside your Automation. Also, beware of the order, the deduplication Query Activity needs to run second.
Selections time-outs
In some cases, you might notice your Query Activities failing because of time-outs. This occurs because, by default, Query Activities in SFMC time out after 30 minutes. You can try rerunning the Selection, and it might succeed, but this will not always be the case. As a workaround, you can try these options:
- Optimize your selections: Ensure you are using Primary Keys to join your tables, and use them in the fields selected for In Results or Not In Results filters.
- Split the Selection: Break down large Selections into smaller manageable steps.
- Request a limit increase: If optimization is not enough, you can contact Salesforce support to request an increase to your time-out limit.
To learn more about this time-out, see Optimizing a SQL Query Activity.
Selections running faster or slower than Query Activities in Automation Studio
All Query Activities from Unaric Segment run inside Salesforce Marketing Cloud via API and will take the same time to run as the same Query created and started in Automation Studio. If you find that Unaric Segment Selections are taking a longer time to complete than their counterparts from Automation Studio or Journey Builder, here are a few points to look at:
- In case you make changes that you want to include, always run your DESelect Segment Selection before using the corresponding Query Activity from Automation Studio.
- Check for Prio Deduplication on your Unaric Segment Selection. If this feature has been applied, two Query Activities will be generated. The first Query Activity will correspond to the normal Selection and the second Query Activity is where the Prio Deduplication applies. Make sure to include both Query Activities.
- Make sure you are using the correct Query Activity.
Discrepancy on results from Query Studio and Unaric Segment
In some cases, running a query in Query Studio might return more records compared to Unaric Segment. This happens because Query Studio creates Data Extensions without automatically setting primary keys, so duplicate records are included, while Unaric Segment uses the primary key defined in your Data Extensions and automatically removes duplicate records.
To fix this:
- Edit your Data Extension in DESelect Segment and remove the primary field (eg. Contact_Key), and click Save.
- Re-add the primary field (eg. Contact_Key) without setting it as a primary key.
- Make the field nullable.
- Run your query again.