Jump to content

Paging through thousands of records


CaptainStarbuck

Recommended Posts

Consider 10,000 images in a directory, like icons, avatars, or someone's recent vacation pictures. Put these all in a MySQL table where each row represents one file, with columns for a filename, description, and some other data. We have code that shows these images in pages but it takes about 1 full minute to move from one page to the next. It seems that for each request the code sorts the database, indexes to the desired row, then builds the current page as a string. I'm looking for much more efficient code that might pre-page the data on the server (assume all pages are the same size) and then have every request just index into the result set at the right position and build the display code more effectively - a more random access approach than sequential.

 

Can someone point me to code that does this, in a package that handles this well?

 

Might this be best done by creating a separate index table whenever the files are updated, where the primary key is the page number and columns for image1, image2, etc are the keys to the images that appear on that page?

 

I know this seems like a problem that would have been solved a decade ago, but algorithms evolve...

 

Thanks!!!

Link to comment
Share on other sites

Yeah, 10k amount of records is nothing for a database.

 

We have code that shows these images in pages but it takes about 1 full minute to move from one page to the next.

 

Please post the code for this problem so we can fix it  :)

Link to comment
Share on other sites

I'm going to guess that the actual page generation time by the server is minimal (less than one second), but that you are using full size images in the content and that the full size images must be fetched by the browser on each page load.

 

Have you actually determined what the page generating time is to isolate if the long page load times are due to the database accesses or due to the time it takes the content to be transfered?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.