t2.type=‘Private’ predicate causes to eliminate this.
Option 1)
SELECT t2.*, t1.*
FROM data AS t1
LET t2 = (SELECT RAW t3 FROM data AS t3 USE KEYS 'Catch:Private:'||t1.`key` WHERE t3.type='Private')[0]
WHERE t1.type='Catch' ;
Option 2)
SELECT t2.*, t1.*
FROM data AS t1
LEFT JOIN data AS t2
ON KEYS 'Catch:Private:'||t1.`key`
WHERE t1.type='Catch' AND (t2 IS MISSING OR t2.type='Private')
Option 3) USE ANSI JOIN
SELECT t2.*, t1.*
FROM data AS t1
LEFT JOIN data AS t2
ON 'Catch:Private:'||t1.`key` = META(t2).id AND t2.type='Private'
WHERE t1.type='Catch' ;
I cannot get option 1 to work. There is a syntax error and adding “… AND t3.type…” isn’t valid either.
The two other options I can get to work
I don’t really see any significant difference in response time from the two options. So I guess from that point it doesn’t really matter which one I choose. Are there any differences in terms of options to tune the queries? I would like to optimise the query indifferently of which one I select (current response time is about 1.30 secs. for 10K docs.)
So basically “reordering” a little of the conditions on t2.type in my own query makes it work like the ANSI query.
SELECT t2.*, t1.*
FROM data AS t1
LET t2 = (SELECT RAW t3 FROM data AS t3 USE KEYS 'Catch:Private:'||t1.`key` WHERE t3.type='Private')[0]
WHERE t1.type='Catch' ;