Random result order when not using order by clause


#1

Hi guys,

I’ve noticed that when you submit a query like this one:

SELECT * FROM bucket WHERE type = ‘voip_call’ and sender = ‘foreign-key’ LIMIT 10

that there’s no default ORDER BY sorting in place and the results I’m getting are randomly selected, which means that the result set changes every time I submit the query. I’ve noticed the same behaviour with the GROUP BY clause, means every time I’m using it I’m getting different result sets.

Best,
Marcel


#2

Yes, your observation is correct.

Thanks,
Gerald


#3

Does this issue can be fixed?


#4

Hi @atom_yang,

There is no issue to be fixed. With N1QL, ORDER BY is required if a specific result order is desired.

Gerald


#5

When I use order by after group by ,my result shows random.


#6

Please try it with 4.5, and post the specific query.