Very slow performance when using petapoco paged fetch

Petapoco Page fetch query is very slow,

This is due to OrderBy clause. If we forget to append orderBy clause in query then Paged fetch will be slower to map.

We need to append OrderBy clause in the query to speed up the pagination functionality.


// slow performance code
var sql = new Sql("select * from tableName left join tableName1 on tableName1.key = tableName.key2");

// Tuned performance code for pagination
var sql = new Sql("select * from tableName left join tableName1 on tableName1.key = tableName.key2");
sql.OrderBy("tableName.CreatedAt DESC");

Leave a Reply