Because of the sorting - everything is output in the lexically computed order of the keys, and because the output is a range that starts when it sees the first key, and only stops when the value higher than the end key is seen.
When a view is output, the content of the view is everything until the key, keys, or startkey or endkey are specified.
Startkey and endkey are start and stop values, not selection specifications.
Let’s look at some sample data:
[1, “T1”, “books”]
[2, “T1”, “books”]
[3, “T2”, “books”]
[4, “T1”, “books”]
[5, “T2”, “books”]
The above is output in the correct sort order - and your startkey and endkey would output everything, because [null, “T1”, null] would match the first and output would continue until there was something lexically greater than your endkey.
Might be clearer with some less wide ranging examples. Using the same data:
?startkey=[1, “T1”, null]&endkey[3, “T1”, “\u0fff”]
Would output:
[1, “T1”, “books”]
[2, “T1”, “books”]
From the source data:
The first row is lexically greater than startkey, so we start outputting.
The second row is not lexically greater than end key, so it is output
The third row is lexically greater than endkey, so it is not output, and output now stops
While:
?startkey=[1, “T1”, null]&endkey[4, “T1”, “\u0fff”]
Would output:
[1, “T1”, “books”]
[2, “T1”, “books”]
[3, “T2”, “books”]
[4, “T1”, “books”]
From the source data:
The first row is lexically greater than startkey, so we start outputting.
The second row is not lexically greater than end key, so it is output
The third row is not lexically greater than endkey, so it is output
and so on.
OR even more explicitly:
?startkey=[2, “T1”, null]&endkey[4, “T1”, “\u0fff”]
Would output:
[2, “T1”, “books”]
[3, “T2”, “books”]
[4, “T1”, “books”]
Sometimes it can be easier to think of it in numbers. If you think of each emitted row of output as a number, then if I ask for data starting with 100 and finishing with 200, I get 100, 101, 102,…
If I ask for everything between 121 and 221 then I’ll get 121, 122, 123, …136, 137, 138, …, 178, 179, 180…
The fact that I specified ‘2’ as the middle digit is relevant only for when output starts, and when it stops.
This is where you have to carefully select the output of your view to accommodate your query types, and the information you want.
Have you included the SubmittedOn because you want the information, or because you want to use it as a selection?