Testuser
Testuser

Reputation: 1745

Does limiting a query improves perfomance?

Would limiting a query to one (or more) result(s) have any noticeable impact on the performance?

For example:

q := datastore.NewQuery("User").Filter("Name =", uniqueUsername)

vs.

q := datastore.NewQuery("User").Filter("Name =", uniqueUsername).Limit(1)

Upvotes: 0

Views: 85

Answers (1)

Jason Hall
Jason Hall

Reputation: 20920

In this case, if there is only one entity that matches the query, I wouldn't expect to see any difference in those two queries. (But feel free to try it out for yourself to find out!)

Upvotes: 1

Related Questions