Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2800

NOT IN clause HANA SQL performance question

$
0
0

Suppose I have two column store tables - a large fact table (FACT) with let's say 10M rows, and a dimension table (DIM) with 1K rows.  The two tables are joined on some arbitrary key, let's say PRODUCT_ID.

 

Which query would perform better?

 

SELECT     FACT.*
FROM     FACT
WHERE     FACT.PRODUCT_ID NOT IN ('A', 'B', 'C')

or

 

SELECT     FACT.*
FROM     FACT INNER JOIN DIM ON          FACT.PRODUCT_ID = DIM.PRODUCT_ID
WHERE     DIM.PRODUCT_ID NOT IN ('A', 'B', 'C')

In other words, is it faster to perform the NOT IN clause on the small dimension table and then join to the large fact table, or simply to perform the NOT IN clause directly on the large fact table?  Or is there no difference?  Assume no secondary indexes have been added to the tables other than primary keys, where PRODUCT_ID is the primary key of the DIM table and PRODUCT_ID is part of a compound primary key of the FACT table.

 

Also, does the situation change if say our FACT table is no longer one table, but a calculation view which joins several transaction tables together to create a fact view before being used in the above scenarios?

 

Cheers,

 

Chris.


Viewing all articles
Browse latest Browse all 2800

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>