When creating attribute relationship filters, the default Very Large Database (VLDB) property for sub query types causes EXISTS statements to appear in the sub queries. This syntax can be costly for most Relational Database Management System (RDBMS) platforms when the fact tables involved are large in size. There is a simple optimization that can be performed, which is to modify this VLDB setting so that temp tables are applied for this type of analysis. The following example from Strategy Tutorial serves to illustrate this point.
Users can define an attribute relationship filter to display those customers who have purchased Godzilla and not To Engineer Is Human:
Users must place the attribute 'Customer' on the template. The resulting SQL, by default, appears as follows:
select a11.CUSTOMER_ID CUSTOMER_ID, max(a12.CUST_LAST_NAME) CUST_LAST_NAME, max(a12.CUST_FIRST_NAME) CUST_FIRST_NAME, sum((a11.QTY_SOLD * (a11.UNIT_PRICE - a11.DISCOUNT))) WJXBFS1 from ORDER_DETAIL a11 join LU_CUSTOMER a12 on (a11.CUSTOMER_ID = a12.CUSTOMER_ID) where ((not ((a11.CUSTOMER_ID) in (select r11.CUSTOMER_ID from ORDER_DETAIL r11 where r11.ITEM_ID in (74)))) and ((a11.CUSTOMER_ID) in (select r11.CUSTOMER_ID from ORDER_DETAIL r11 where r11.ITEM_ID in (184))) and a11.ITEM_ID in (184)) group by a11.CUSTOMER_ID


The new SQL for this query is as follows:
select distinct r11.CUSTOMER_ID CUSTOMER_ID into #ZZRF00 from ORDER_DETAIL r11 where r11.ITEM_ID in (184) select distinct r11.CUSTOMER_ID CUSTOMER_ID into #ZZRF01 from ORDER_DETAIL r11 where r11.ITEM_ID in (74) select a13.QUARTER_ID QUARTER_ID, max(a15.QUARTER_DESC) QUARTER_DESC, a11.CUSTOMER_ID CUSTOMER_ID, max(a14.CUST_LAST_NAME) CUST_LAST_NAME, max(a14.CUST_FIRST_NAME) CUST_FIRST_NAME, sum((a11.QTY_SOLD * (a11.UNIT_PRICE - a11.DISCOUNT))) WJXBFS1 from ORDER_DETAIL a11 join #ZZRF00 pa12 on (a11.CUSTOMER_ID = pa12.CUSTOMER_ID) join LU_DAY a13 on (a11.ORDER_DATE = a13.DAY_DATE) join LU_CUSTOMER a14 on (a11.CUSTOMER_ID = a14.CUSTOMER_ID) join LU_QUARTER a15 on (a13.QUARTER_ID = a15.QUARTER_ID) where ((not (exists (select * from #ZZRF01 ps21 where ps21.CUSTOMER_ID = a11.CUSTOMER_ID))) and a11.ITEM_ID in (184)) group by a13.QUARTER_ID, a11.CUSTOMER_ID drop table #ZZRF00 drop table #ZZRF01