Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8254105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:05:27+00:00 2026-06-08T01:05:27+00:00

I know this question has been asked many times before, but I haven’t found

  • 0

I know this question has been asked many times before, but I haven’t found an answer that addresses my specific case.

Using PHP & MySQL…

I’m about to add user profile pics to an app and as I see it I have several options. Two of which are as follows:

1. Make no reference to the image in the database and store the images
like so:-

  • /assets/avatars/32px/userid.jpg

  • /assets/avatars/90px/userid.jpg

  • /assets/avatars/256px/userid.jpg

This would mean no extra database lookups as I will already have the relevant userid.

1. Store the relative path in the users_meta table and retrieve the url’s using a join when I retrieve user data.

What are the pro’s con’s of each method? And if in your opinion, neither method is the best way, what would you consider to be the most efficient and scaleable way of storing/referencing and retrieving user profile pics.

Many thanks

EDIT: To add some more detail :

My concern with option number 1 is that I am unsure how the filesystem would cope with 1 million+ files in a single directory. Would it slow to a crawl? If so how could I work around this? Is there a structure that would eliminate this potential issue? Perhaps using the time a user joined as part of the url and storing the images by the month.

e.g. /assets/avatars/10_2012/small/userid.jpg

with 10_2012 meaning all users who registered in October of 2012.

Or alternatively store only 1000 images in each directory and access the like so:

  • /assets/avatars/0/small/userid.jpg
  • /assets/avatars/1000/small/userid.jpg
  • /assets/avatars/2000/small/userid.jpg

Adding a new directory every time the app reaches 1000 * n users registered.

Would this offer an advantage?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:05:28+00:00Added an answer on June 8, 2026 at 1:05 am

    As you correctly noted – in case of using file system for your needs you don’t have to do an extra DB lookup. This saves you time and resources.

    The only benefit of using a DB for this that I can see is a “single-point” back-up. But I doubt it’s a very valid “pro” or if it even outweighs the extra complexity introduced by an extra level of indirection caused by a DB lookup

    Edit (to match the edit in the question): The way file systems work greatly depends on the operating system. What is your target platform?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this is a question that has been asked many times before, but
I know that this question has been asked many times before in different guises
NOTE: I know that this has been asked many times before, but none of
I know this question has been asked many times before but I can't find
I know this question has been asked so many times before but I couldn't
I know that this question has a been asked many times, but I still
I know this question has been asked many times before but I tried out
I know this questions has been asked many times before -- but I haven't
I know this question has been asked many times before, but any of the
Ok I know this question has been asked many many many times before, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.