I have got a question which returns 30 rows. I am writing code which will paginate individuals 30 rows into 5 records per page with an AJAX call.

  1. Can there be any reason to come back just individuals 5 records in the presentation layer? Would there be any benefits when it comes to speed or will it just get all of the rows underneath the hood anyways?

  2. If that's the case, how do you really get it done in Sybase? I understand Oracle has Rownum and MS Sql has such like, however i can't appear to locate a similar function in Sybase.

Unless of course your record length is big, the main difference between 5 and 30 rows ought to be completely undetectable towards the user. Actually there is a significant potential the multiple DB calls will harm performance a lot more than help. Just return all 30 rows with the idea to your middle tier or perhaps your presentation, whatever will work better.

I have never labored with Sybase, but here is a link that describes how to behave similar:

http://www.dbforums.com/sybase/1616373-sybases-rownum-function.html

Because the solution involves a temp table, you may also apply it pagination. In your initial query, place the 30 rows right into a temporary table, and give a column for page number (the very first five rows could be the first page, the following five page 2 and so forth). On subsequent page demands, you query the temp table by page number.

Unsure the way you start cleaning the temp table, though. Possibly once the user's session occasions out?

For 30 records, it's most likely not really worth disturbing with pagination whatsoever.

I believe in sybase you should use

select top 5 * from table 
where order-by-field > (last record of previous calls order-by-field)  
order by order-by-field

just make certain you apply the same order by every time.

For benefit I suppose it is dependent on the number of rows we're speaking and just how large the table is etc.

To be sure completely with jmgant, however, if you wish to get it done anyway, the procedure goes something similar to this:

  1. Choose top ten products and store in X
  2. Choose 5 best products and store in Y
  3. X-Y

This whole process sometimes happens in 1 SQL statement.