Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pagination ..... better approach

 
Naveen Mishra
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi..
I'm in delima what could be a better approach for pagination in a web - based application : it is get data into the memory for onceonly and try manage the things here only ( don't know if it can be done in general ways but if done ... IT INVOLVS MEMORY OCCUPIED , it can go serious if records are in huge number like google search results )

OR

Fetch some n number of records each time and display them ( IT INVOLVS LOTs of CALLS TO DB )

...
which way to go and why ?


Thanks .
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Funny you should mention Google: their policy is to never display more than 1,000 links for a query. Sure, they tell you that there were 2,870,000 hits but they won't show you more than the first 1,000. You might consider copying that idea. Then you just have to read the first 1,000 rows into memory, and your concerns about many calls to the database go away.

Of course this assumes you show the records that are the most important to the user first, like Google does. But you are already doing that, aren't you? You wouldn't make the user click through 20,000 pages in a web application, right?
 
stu derby
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Clapham:
Funny you should mention Google:


Google also doesn't use a relational database for their search engine.
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by stu derby:
Google also doesn't use a relational database for their search engine.
Perhaps not. But if they had to be prepared to materialize all 2-million pages that matched my search, they would have the same problem as Naveen does. The point is that showing data one page at a time and having millions of rows of that data are features that should not coexist in the same design.
 
Naveen Mishra
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. Thanks Paul and Stu for your precious comments on the issue .
I think , I could procceed with Paul's hybrid approach of fetching some good number of records in the memory and play arround with it until user goes beyond those records .It reduces both calls to DB and need of memory to keep huge amount of data.

Thanks again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic