I see that this info was also lost when copying from Discord. Obviously, that is needed here!
I see that I sent the EXPLAIN for a slightly different query as I did not include the locationtype="1"
(one of the other attempts - but it made no difference).
Here is the correct one for the query with:
((locationlevel2='91' AND locationtype='1')
OR (locationlevel4='91' AND locationtype='2'))
EXPLAIN:
{
"plan": {
"#operator": "Sequence",
"~children": [
{
"#operator": "Sequence",
"~children": [
{
"#operator": "IndexScan3",
"index": "def_type_trip_location_2",
"index_id": "80045c43b64064b5",
"index_projection": {
"primary_key": true
},
"keyspace": "data",
"namespace": "default",
"spans": [
{
"range": [
{
"high": "\"FishingTrip\"",
"inclusion": 3,
"index_key": "`type`",
"low": "\"FishingTrip\""
},
{
"high": "\"1\"",
"inclusion": 3,
"index_key": "`locationtype`",
"low": "\"1\""
},
{
"inclusion": 0,
"index_key": "`locationlevel1`"
},
{
"inclusion": 0,
"index_key": "`locationlevel2`"
},
{
"inclusion": 0,
"index_key": "`locationlevel4`"
}
]
},
{
"range": [
{
"high": "\"FishingTrip\"",
"inclusion": 3,
"index_key": "`type`",
"low": "\"FishingTrip\""
},
{
"high": "\"2\"",
"inclusion": 3,
"index_key": "`locationtype`",
"low": "\"2\""
},
{
"inclusion": 0,
"index_key": "`locationlevel1`"
},
{
"inclusion": 0,
"index_key": "`locationlevel2`"
},
{
"inclusion": 0,
"index_key": "`locationlevel4`"
}
]
}
],
"using": "gsi"
},
{
"#operator": "Fetch",
"keyspace": "data",
"namespace": "default"
},
{
"#operator": "Parallel",
"~child": {
"#operator": "Sequence",
"~children": [
{
"#operator": "Filter",
"condition": "(((((`data`.`type`) = \"FishingTrip\") and ((((`data`.`locationlevel2`) = \"91\") and ((`data`.`locationtype`) = \"1\")) or (((`data`.`locationlevel4`) = \"91\") and ((`data`.`locationtype`) = \"2\")))) and ((`data`.`catchkeys`) is valued)) and (0 < array_length((`data`.`catchkeys`))))"
},
{
"#operator": "InitialGroup",
"aggregates": [
"sum(array_length((`data`.`catchkeys`)))"
],
"group_keys": [
"(`data`.`year`)"
]
}
]
}
},
{
"#operator": "IntermediateGroup",
"aggregates": [
"sum(array_length((`data`.`catchkeys`)))"
],
"group_keys": [
"(`data`.`year`)"
]
},
{
"#operator": "FinalGroup",
"aggregates": [
"sum(array_length((`data`.`catchkeys`)))"
],
"group_keys": [
"(`data`.`year`)"
]
},
{
"#operator": "Parallel",
"~child": {
"#operator": "Sequence",
"~children": [
{
"#operator": "InitialProject",
"result_terms": [
{
"expr": "(`data`.`year`)"
},
{
"as": "count",
"expr": "sum(array_length((`data`.`catchkeys`)))"
}
]
}
]
}
}
]
},
{
"#operator": "Order",
"sort_terms": [
{
"desc": "\"desc\"",
"expr": "(`data`.`year`)"
}
]
}
]
}
}
And here is one for the query without the OR (with just the one locationlevel/locationtype):
locationlevel2='91' AND locationtype='1'
EXPLAIN:
{
"plan": {
"#operator": "Sequence",
"~children": [
{
"#operator": "Sequence",
"~children": [
{
"#operator": "IndexScan3",
"index": "def_type_trip_location_2",
"index_id": "80045c43b64064b5",
"index_projection": {
"primary_key": true
},
"keyspace": "data",
"namespace": "default",
"spans": [
{
"exact": true,
"range": [
{
"high": "\"FishingTrip\"",
"inclusion": 3,
"index_key": "`type`",
"low": "\"FishingTrip\""
},
{
"high": "\"1\"",
"inclusion": 3,
"index_key": "`locationtype`",
"low": "\"1\""
},
{
"inclusion": 0,
"index_key": "`locationlevel1`"
},
{
"high": "\"91\"",
"inclusion": 3,
"index_key": "`locationlevel2`",
"low": "\"91\""
}
]
}
],
"using": "gsi"
},
{
"#operator": "Fetch",
"keyspace": "data",
"namespace": "default"
},
{
"#operator": "Parallel",
"~child": {
"#operator": "Sequence",
"~children": [
{
"#operator": "Filter",
"condition": "(((((`data`.`type`) = \"FishingTrip\") and (((`data`.`locationlevel2`) = \"91\") and ((`data`.`locationtype`) = \"1\"))) and ((`data`.`catchkeys`) is valued)) and (0 < array_length((`data`.`catchkeys`))))"
},
{
"#operator": "InitialGroup",
"aggregates": [
"sum(array_length((`data`.`catchkeys`)))"
],
"group_keys": [
"(`data`.`year`)"
]
}
]
}
},
{
"#operator": "IntermediateGroup",
"aggregates": [
"sum(array_length((`data`.`catchkeys`)))"
],
"group_keys": [
"(`data`.`year`)"
]
},
{
"#operator": "FinalGroup",
"aggregates": [
"sum(array_length((`data`.`catchkeys`)))"
],
"group_keys": [
"(`data`.`year`)"
]
},
{
"#operator": "Parallel",
"~child": {
"#operator": "Sequence",
"~children": [
{
"#operator": "InitialProject",
"result_terms": [
{
"expr": "(`data`.`year`)"
},
{
"as": "count",
"expr": "sum(array_length((`data`.`catchkeys`)))"
}
]
}
]
}
}
]
},
{
"#operator": "Order",
"sort_terms": [
{
"desc": "\"desc\"",
"expr": "(`data`.`year`)"
}
]
}
]
}
}