The CreatorCon Call for Content is officially open! Get started here.

View only unique records in List view of the table

Garima Pant1
Tera Contributor

There are over 10,000,000 records in a custom table, out of which only 4400 records are unique. I am trying to create a query business rule that will display only those distinct records and filter out the duplicates. 

Not able to achieve this. So far I have achieved this:

var osCount= [];
var records;

var gr = new GlideAggregate('u_softwares_on_windows_servers');
gr.addQuery("cmdbci_sys_class_name", "cmdb_ci_win_server");
gr.addQuery("cmdbci_operational_status", "1");
gr.addAggregate('count');
gr.orderByAggregate('count');
gr.groupBy('sp_sys_id');
gr.query();
while (gr.next()) {
osCount.push(gr.sp_sys_id.trim());

}


 for (var i = 0; i < osCount.length; i++) {

 return osCount[i];

}

 

 

 

2 REPLIES 2

Maik Skoddow
Tera Patron
Tera Patron

Why don't you delete all the records which are not unique?

It makes no sense to implement a query business rule just for cutting out nearly 10 Million records. This will massively degrade the performance of your instance!

Kind regards
Maik

It is a database view fetching records from cmdb tables, deleting won't solve the issue.