I currently have a server side paging query as such:

```
SELECT * FROM (SELECT a.*, rownum rnum FROM (
        ( /* Insert Query Here */ ) ) a
      WHERE rownum <= ((page_number + 1) * page_size))
      WHERE rnum >= (((page_number  + 1) * page_size)) - (page_size - 1);

```

The problem, however, is trying to determine what the user is sorting on as this is tied to a gridview. Currently, I'm using:

```
ORDER BY 
        CASE sort_direction
          WHEN 'ASC' THEN
            CASE sort_column
              WHEN 'PRIMARY_KEY' THEN
                primary_key
              ELSE key
            END
        END    
        ASC,
        CASE sort_direction
          WHEN 'DESC' THEN
            CASE sort_column
              WHEN 'PRIMARY_KEY' THEN
                primary_key
              ELSE key
            END
        END    
        DESC

```

I'm using this on every query I stick into the server side paging scheme. The problem is that when I have a grid that has quite a few fields, the performance degrades substantially. Is there any other way to do this? Do I need to simply set less fields to allow paging?