• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

pagination ..... better approach

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 .
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic