Searching efficiently, getting occasional 503 timeout

Hello!

We have an auth0 tenant with less than 10k users, and we have built a user administration page inside our app that paginates this list in chunks of 25 users. This query usually takes less than 600 ms.

Occasionally we get a 503 - which i understand to be a query that takes more than 2 seconds

 [{"status": "503", "detail": "The query exceeded the timeout. Please try refining your search criteria. See https://auth0.com/docs/best-practices/search-best-practices", "title": "Service Unavailable"}]

I have read the search best practices guide and think we’re doing everything correctly, but I wanted to see if someone would look at our query and see if we are doing something less efficiently than we should be. Again we’e only fetching 25 records at a time at maximum.

"api/v2/users?per_page=25&page=0&fields=user_id%2Cfamily_name%2Cgiven_name%2Cemail%2Clast_login%2CaltSecurityIdentities%2Cidentities%2Cgroups%2Ccreated_at%2Cuser_metadata%2Capp_metadata&search_engine=v3&include_totals=true&sort=email:1&q=identities.connection:(%22chris%22)"

so
per_page 25
page 0
Included fields (family name, given name, email, last login, security info, user and app metadata, identities, created at)
include totals
sort on email
where connection name = chris

Are we asking for too many fields here? Any other insight into what may cause this query to return a 503? (We saw this yesterday twice btw, at 8:30am EST and at 3pm EST) and a total of 9 times in the last 30 days.

Thank you,

Chris Ward

The user search endpoint is limited to returning 1000 users (https://auth0.com/docs/users/search/v3/get-users-endpoint#limitations) so as mentioned at (https://auth0.com/docs/best-practices/search-best-practices) is not recommended to use overly general search criteria that is guaranteed to include a population of users greater than the previous limit.

What’s the use case for wanting to paginate over all the users of a specific connection without any other search criteria?

Thanks for answering - we are aware of the 1000 result maximum and that really isn’t a problem for us - we do have a search / filter functionality in the application - this is just the default view.

My main question is about the performance of the query itself. We receive 503's occasionally and were wondering if we could enhance the request to be more efficient, or if we were asking for too many fields. We are only ever returning 25 users per page, but the 503 would indicate that still is taking more than 2 seconds.

Any other insight on this?