API complexity not adding up

Query 1
Query a board for its items without any column values.

query ($boardId: [Int]) {
    boards(ids: $boardId) {
        items {
            id
        }
    }
    complexity {
        query
    }
}

complexity: 1020


Query 2
Taking the results of Query 1 Items array and passing it as $itemsIds

query ($itemIds: [Int], $columnId: [String]) {
        items (ids: $itemIds) {
            id
            column_values(ids: $columnId) {
                value
            }
        }
        complexity {
            query
        }
    }

Complexity 46


Query 3
Query board returning column values - this is a combination of 1 & 2 above.

query ($boardId: [Int], $columnId: [String]) {
    boards(ids: $boardId) {
        items {
            id
            column_values(ids: $columnId) {
                value
            }
        }
    }
    complexity {
        query
    }
}

Complexity 12020


By doing query 1 and passing the results to query 2, the cost is a combined total of 1066. By doing just query 3 - the cost is 12020 - 11.27X more complex, for what I think is the same number of objects handled.

I realize the boards query to get items is expensive because its a search of item documents for that board ID (query 1). But once that’s done, the item documents are found and the column values retrieved from them. That’s second part is the same as what’s happening in Query 2 which cost 46, but now is 11000 more to get the column values vs 46. I could see a bit of an increase, but this is orders of magnitude more. Its seems like since getting the list of items from the board (all) is a search of the database and that has a cost multiplier - that multiplier is then being applied to the sub-queries to get the items themselves when it shouldn’t be.

@codyfrisch

I think that querying items directly (without the board) is more costly for some reason.

Try changing 3 to use the board as in 2.

Query 3 is most expensive. Query 1+2 together is 1/10th yet gets the same data in two vs one query. And its not just a slight increase in complexity - its orders of magnitude.

{note: i swapped 2 & 3 from initial posting to make it more clear)

@codyfrisch

Thanks for the clarification. I stand corrected. That’s very interesting.

One note however: although the COMPLEXITY is not reduced by using the board in the query, there is an additional API limitation that comes into effect: Additional rate limit for items query (monday.com)

There we go.

Its default complexities, if you don’t specify a limit on a query that gets all items, it has a default of 1000. So that is what’s increasing the complexity - its calculated on the assumption of 1000 items.

Would be nice if the query cost was calculated based on the number of actual items returned…

items (limit: #, page: #) {

}

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.