Query Entity: fetchtotalcount is not working

Dear Team,

Could someone help me to understand the below issue please.

I am trying to fetch the total count of the records from DB view. When I give fetchTotalCount=true it's throwing an error 'Expression evaluation error at function a!queryEntity [line 2]: An error occurred while retrieving the data. Details: Unexpected error executing query'. If I change the fetchTotalCount=false, it's working fine. Sample  code is below:

a!queryEntity(
entity: cons!DB_VIEWS_DSE,
query: a!query(
selection:
a!querySelection(
columns: a!queryColumn(
field: "id"
)
),
pagingInfo:
a!pagingInfo(
startIndex: 1,
batchSize: 1,
sort: {
a!sortInfo(field: "id", ascending: false())
}
)
),
fetchtotalcount: true
)

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    It seems like your query hits a database view. How long does the query take? To fetch the totalCount, Appian has to query the view twice. Once for the totalCount, second for the actual data. If a single query is just below the timeout, a second query will raise the bar.

  • Hi Stefan, Thanks for the response. 

    I agree with you. Two DB calls will happen if I used totalcount is true. But I am fetching only 1 record from DB and the total count of the table. Usually It should not take more than 3 to 4 sec. But my code taking around 8 to 10 sec to display the error message. I just really want to know how the fetchtotalcount will work internally. 

    FYI, this is happening only for few DB views not all. Could you please help me to know what is the potential cause for fetching only one record and totalcount

Reply
  • Hi Stefan, Thanks for the response. 

    I agree with you. Two DB calls will happen if I used totalcount is true. But I am fetching only 1 record from DB and the total count of the table. Usually It should not take more than 3 to 4 sec. But my code taking around 8 to 10 sec to display the error message. I just really want to know how the fetchtotalcount will work internally. 

    FYI, this is happening only for few DB views not all. Could you please help me to know what is the potential cause for fetching only one record and totalcount

Children