Hello,
I am seeing some weird behavior with my Analytics indexes and am struggling to figure out why is it behaving the way it is…
Here is my index definition:
create index tran_docNum_ix on tranData(DocNum:STRING,`$MdfdTmstmp`:STRING);
Query:
SELECT DISTINCT RAW DocNum
FROM tranData
WHERE DocNum IN ["10112746"]
AND `$MdfdTmstmp` BETWEEN "2022-06-15T00:00:00" AND "2022-06-17T23:59:59"
This works as expected and uses the tran_docNum_ix index.
But if I put multiple DocNum in the IN array, it does not pick up the index!
SELECT DISTINCT RAW DocNum
FROM tranData
WHERE DocNum IN ["10112746","12345"]
AND `$MdfdTmstmp` BETWEEN "2022-06-15T00:00:00" AND "2022-06-17T23:59:59"
Index was not used!
Taking this even further the following queries does not pick the index either:
Using LET but with just 1 DocNum
SELECT DISTINCT RAW DocNum
FROM tranData
LET available_daily_docs = ["10112746"]
WHERE DocNum IN available_daily_docs
AND `$MdfdTmstmp` BETWEEN "2022-06-15T00:00:00" AND "2022-06-17T23:59:59"
Note that the DocNum field is not an array in the document. So I don’t think it would make sense to create an index with (unnest DocNum:STRING)
unless I am misunderstanding array indexes in Analytics.
Thanks for your help with this…