GlideAggregate, vs GlideRecord getRowCount, which is faster?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2022 02:05 PM
Hello. We are looking to determine counts of a particular criteria of tickets. Our system currently has 7M tickets, and we are trying to create reports that look at counts of these tickets. Our typical ideas usually involve GlideRecord coding and using getRowCount, but want to know if GlideAggregate will result in faster performance.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2022 02:12 PM
Yes, GlideAggregate will be faster. Suggest you to check link that talks about difference with execution time for both as a difference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2022 02:26 PM
So even with only one aggregate value being pulled up, it is still faster than getRowCount?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2022 02:36 PM
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2022 05:49 PM
Hi tahnalos,
I don't know the internal of ServiceNow but I think ServiceNow is using jdbc to connect to the database.
.getRowCount() is probably doing a .getRow() on the resultset. That is, it's getting all the query records into a resultset and counting how many rows there are.
https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSet.html#getRow--
GlideAggregate() is probably doing a "SELECT COUNT" sql query.
https://www.w3schools.com/sql/sql_count_avg_sum.asp
Since .getRow() is executed on the Java application side while SELECT COUNT on the database, SELECT COUNT would be faster. Thus, GlideAggregate() would be faster.