My Products
Help
Eivfjeld
CONTRIBUTOR **

Slow/failing generalLedgerPeriodBalance query

by Eivfjeld

Hi

I'm having problems with the following query:

{
useCompany(no: 3757847)
{
generalLedgerPeriodBalance(filter: {_and: [ {year: {_eq: 2022} }, {period: {_eq: 12} } ] })
{
totalCount
pageInfo {hasNextPage, hasPreviousPage, startCursor, endCursor}
items
{
accountNo, year, period, obDomestic, cbDomestic
joinup_GeneralLedgerAccount
{
name
}}}}}

It takes a long time ( > 40 seconds) and sometimes I get the following error after 60 seconds:

 

{"errors": [
{"message": "Failed to execute 'text' on 'Response': body stream already read",
"stack": "TypeError: Failed to execute 'text' on 'Response': body stream already read
at https://docs.business.visma.net/graphiql/static/js/main.50d3c8a2.js:2:981812"
}]}

If I remove the filter or the joinup (keeping the filter) it works fine.
Is there anything that can be done to improve this either with the query or the system?

3 REPLIES 3
Eivfjeld
CONTRIBUTOR **

by Eivfjeld

We are having the same problem again with generalLedgerPeriodBalance.  "code":"TIMEOUT".

by Marius Bancila

We have improved the execution of queries from joined tables. This is described in detail here: https://docs.business.visma.net/docs/features/unoptimized

 

Mind that this has some limitations and depending on your needs, you might need to execute queries with the unoptimized flag. By default, they are now executed in an optimized manner.

by Marius Bancila

Unfortunately, you cannot do anything right now to fix the long time it takes to execute.

 

Fortunately, this is a performance issue that we were aware of and has been fixed this week. If everything goes well, it will be released to production next Thursday.

 

The problem occurs because of the joined table. For one query on the GeneralLedgerPeriodBalance table that returns N elements, there are additional N queries to the GeneralLedgerAccount table. This is known as the N+1 problem and we are working to optimize it so that only 2 queries are made.

 

I will keep you posted when the release it.