This looks good. How about a couple more where you use upper in the where clause and in the group by clause? The code paths will be different in these cases (since the expression will get evaluated on the server path and it'll hit some attempts to optimize the query by setting/not setting the scan key, etc).