Well that performs well: 270-300ms. As soon as I change it to return * instead of COUNT(1) it goes up to 1.8-2s
The EXPLAIN for the count:
{
"plan": {
"#operator": "Sequence",
"~children": [
{
"#operator": "IndexScan3",
"covers": [
"cover ((`data`.`type`))",
"cover ((`data`.`locationtype`))",
"cover ((`data`.`statslocation`))",
"cover ((`data`.`locationlevel1`))",
"cover ((`data`.`locationlevel2`))",
"cover ((`data`.`locationlevel4`))",
"cover ((`data`.`fisherytype`))",
"cover ((meta(`data`).`id`))"
],
"filter_covers": {
"cover ((`data`.`type`))": "FishingTrip"
},
"index": "def_type_trip_location_2",
"index_id": "ae360167e11b075",
"index_projection": {
"entry_keys": [
0,
1,
4,
5
]
},
"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": "`statslocation`"
},
{
"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": "`statslocation`"
},
{
"inclusion": 0,
"index_key": "`locationlevel1`"
},
{
"inclusion": 0,
"index_key": "`locationlevel2`"
},
{
"inclusion": 0,
"index_key": "`locationlevel4`"
}
]
}
],
"using": "gsi"
},
{
"#operator": "Parallel",
"~child": {
"#operator": "Sequence",
"~children": [
{
"#operator": "Filter",
"condition": "((cover ((`data`.`type`)) = \"FishingTrip\") and (((cover ((`data`.`locationtype`)) = \"1\") and (cover ((`data`.`locationlevel2`)) = \"91\")) or ((cover ((`data`.`locationtype`)) = \"2\") and (cover ((`data`.`locationlevel4`)) = \"91\"))))"
},
{
"#operator": "InitialGroup",
"aggregates": [
"count(1)"
],
"group_keys": []
}
]
}
},
{
"#operator": "IntermediateGroup",
"aggregates": [
"count(1)"
],
"group_keys": []
},
{
"#operator": "FinalGroup",
"aggregates": [
"count(1)"
],
"group_keys": []
},
{
"#operator": "Parallel",
"~child": {
"#operator": "Sequence",
"~children": [
{
"#operator": "InitialProject",
"result_terms": [
{
"expr": "count(1)"
}
]
}
]
}
}
]
}
}
and for the * query:
{
"plan": {
"#operator": "Sequence",
"~children": [
{
"#operator": "IndexScan3",
"index": "def_type_trip_location_2",
"index_id": "ae360167e11b075",
"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": "`statslocation`"
},
{
"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": "`statslocation`"
},
{
"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`.`locationtype`) = \"1\") and ((`data`.`locationlevel2`) = \"91\")) or (((`data`.`locationtype`) = \"2\") and ((`data`.`locationlevel4`) = \"91\"))))"
},
{
"#operator": "InitialProject",
"result_terms": [
{
"expr": "self",
"star": true
}
]
}
]
}
}
]
}
}
Does that give any clue? I can see there are some differences.