Area: API
Sub-Area: Performance
Applies to: OSS + Cloud
Issue
Search queries and GraphQL API calls time out, fail, or take a long time to complete. This usually happens with large result sets, deeply nested queries, or very large pages.
You may see one of these errors:
maximum query depth exceeded <depth> > <limit>maximum query complexity exceeded <complexity> > <limit>- A GraphQL error with code
DEADLINE_EXCEEDED, which maps to HTTP 504 (a server-side timeout)
You Might Be Asking
- Why does my GraphQL query fail with "maximum query depth exceeded" or "maximum query complexity exceeded"?
- How do I page through a large number of search results without timing out?
- How do I filter by platform in a GraphQL search?
Cause
- The query is too deep or too complex. The default maximum query depth is 50. The default maximum complexity is 2010 in OSS v1.9.0 and 2100 in DataHub Cloud v2.4.4. A query over either limit fails with the "maximum query depth exceeded" or "maximum query complexity exceeded" error.
- The page is too large. A page with minimal attributes can return 1,000 to 2,000 results. For very complex requests with many nested objects, the DataHub docs recommend a
countof 20 to 25. - You are using offset paging (
searchwithstartandcount) for deep pagination. Thesearch*APIs are designed for shallow pagination (less than about 50) and can't page beyond 10,000 results. - The query asks for more entity types than it needs.
Solution
-
Reduce the query scope.
- Add filters to narrow the results.
- List only the entity types you need in
types. - Lower
countfor complex requests. Use 20 to 25 when the query has many nested objects.
-
Filter with full URNs. The
platformfield holds URNs. Useurn:li:dataPlatform:snowflake, notsnowflake. Not every filter field is a URN field. For example,origin(Environment) takes a plain value such asPROD. UseorFilters, becausefiltersis deprecated. Entries inside oneandlist are ANDed. Separate entries are ORed. -
Use
scrollAcrossEntitiesfor deep or bulk pagination. Leave outscrollIdon the first request. Pass the returnednextScrollIdasscrollIdon the next request.queryis required.ScrollAcrossEntitiesInputhas nostartand nofiltersfield, and sending either one fails validation. Sort byurnso the order is stable. Don't sort by_scorefirst.
query scrollDatasets($scrollId: String) {
scrollAcrossEntities(
input: {
types: [DATASET]
query: "your search"
count: 100
scrollId: $scrollId
orFilters: [
{ and: [{ field: "platform", values: ["urn:li:dataPlatform:snowflake"] }] }
]
sortInput: { sortCriteria: [{ field: "urn", sortOrder: ASCENDING }] }
}
) {
nextScrollId
count
total
searchResults {
entity {
urn
type
}
}
}
}
entity is an interface, so select type-specific fields such as name inside a fragment like ... on Dataset { name }.
If you use offset search for a short list, stop when start is greater than or equal to total.
-
Avoid deeply nested queries.
- Read lineage with the
searchAcrossLineageorscrollAcrossLineageroot queries. The DataHub docs recommend them for all lineage queries. They support depth greater than 1 through thedegreefilter, for exampledirection: UPSTREAMwithorFiltersondegree. - Dataset also has a
lineage(input: LineageInput!)field. - Fetch several known entities in one request with
entities(urns: [...]). Use inline fragments for type-specific fields. - Split a large nested query into separate requests.
- Read lineage with the
-
If queries still time out.
- On Cloud, contact DataHub Support. Send the slow query and the timestamps of the failures. The depth and complexity limits are server settings, so contact DataHub Support if you need them reviewed.
- On OSS, the depth and complexity limits are GMS settings (
GRAPHQL_QUERY_DEPTH_LIMITandGRAPHQL_QUERY_COMPLEXITY_LIMIT). Simplify the query first.