• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Suggest me a best way to do this

 
Sivaraman Lakshmanan
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am querying a large table with millions of record based on some condition. Say this results in a 70 thousand records. Then again this 70 thousand records are filtered based on 2 three levels of conditions and finally I get a 30 thousand records.
I want to achieve pagination and I should not hit the database again as well,Currently I do this way.
I read all the 30 thousand records and store all the records in a file. I just use file pointers and manipulate things and achieve pagination to show 1000 records per page. Whenever the user request for the next page, I go to the file read it and display the next page and so on
But I feel this is not the efficent way to do this as I get lot of errors while I do paginations because of the file pointers.
Can somebody enlight me by suggesting an efficent method to do this.

Thanks in Advance

Regards,
Sivaraman.L
 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What database do you use?

If you use MYSQL the limit clause should be something for you to look into
 
Sivaraman Lakshmanan
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I use DB2 7.0. as the Database

Reagrds,
Sivaraman.L
 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry! DB2 does not have a limit clause. Maybe there is a workaround like in MSSQL

with mysql you only select the rows that you limit

Sorry that I couldn't help you
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34218
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
db2 has:
FETCH FIRST X ROWS ONLY
which works like the limit clause.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic