Sorting Large data by column in datagrid

I have 1 million records in my inbuilt mendix database. I am trying to sort it in column by column basis. I have added sort order to each column. But I am not able to sort it. I get error. This is the error I get Failed to fetch Error: Failed to fetch. Can this be solved in any way? 
1 answers

Setting an index on the columns you use for sorting should help...