Improved last page calculation.

Improved last page calculation when page size is changed on last page.
e.g. Suppose there are total 12 records and page size is set to 5 records/page. Go to last page, which should be 3, change page size to 10. Page#2 should be selected and it should show 2 records on it.
Fix: Postgres generated SQL wouldn't allow a row to be inserted by Editor due to an incorrect sequence count