load( /*This rule queryEntityRule1 should have only one column to fetch. This is used just to know the total count of DB data */ local!dataSubset: rule!queryEntityRule1( pagingInfo: a!pagingInfo( startIndex: 1, batchSize: - 1 ) ), local!isModValue: if(mod(local!dataSubset.totalCount, cons!EXPORT_TO_EXCEL_BATCH_SIZE)>0, true, false), /*This batch size constant signifies how many rows the query will pull in one batch. you can configure this batch size based on your need. In my case I have set it up with 100 */ local!totalPageCount: int(local!dataSubset.totalCount/cons!EXPORT_TO_EXCEL_BATCH_SIZE), with( local!data: apply(rule!getDataForExcelExport, enumerate(local!totalPageCount)), /* This rule!getDataForExcelExport takes the batch number as input and calls the query per batch. I have the details of this rule separately. */ local!records: reduce(fn!append,{},local!data), local!allData: if(local!isModValue, append(local!records, rule!getDataForExcelExport(local!totalPageCount)), local!records), 'type!{urn:appian:plugin:datasubsetdownload:types}ExportableDataSubset'( datasubset: todatasubset(local!allData, a!pagingInfo(startIndex: 1, batchSize: -1)), fieldNames: { }, fieldLabels: { }, filename: "Excel file" ) ) )