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

  • Home
  • SEARCH
  • 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 250981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:33:23+00:00 2026-05-11T21:33:23+00:00

What is the most efficient solution when you need to record some data on

  • 0

What is the most efficient solution when you need to record some data on every page view in your application – should you write to a file or write to the database?

Or maybe neither – perhaps you should cache the data in memory or a file and only write it to the database (or file system if you use a memory cache) occasionally?

  • 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-05-11T21:33:23+00:00Added an answer on May 11, 2026 at 9:33 pm

    If it’s purely recording a small amount of data with no subsequent lookups, straight file I/O is almost guaranteed to be more efficient. You’re losing all the advantages of a DBMS though — indexing, transactional integrity (really, ACID in general), concurrent access, etc..

    It almost sounds like you’re talking about what amounts to simple logging. If that’s the case, and you don’t need to do frequent complex queries on the resulting data, you’re probably better off with straight file I/O if performance is a serious issue. Be careful of concurrent-write issues, though.

    If the properties of an RDBMS are desirable, you might think about using SQLite, which for simplistic loads will get you better performance than most RDBMSs with less overhead, at the cost of some of the benefits (highly concurrent access and availability over the network to other machines are a couple of the “biggies”). It still wouldn’t be as fast as straight file I/O in the general case, though.

    Your later mention of it being for page view tracking causes me to ask: Are you incrementing a counter, rather than logging data about the page view? If so, I’d strongly suggest going with something like SQLite (doing something like UPDATE tbl SET counter = counter+1). You really don’t want to get into the timing issues involved in doing this by hand — if you don’t do it right, you’ll start losing counts on simultaneous access (A reads “100”, B reads “100”, A writes “101”, B writes “101”; B should have written 102, but has no way of knowing that).

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

Sidebar

Related Questions

What's the most efficient algorithm to find the rectangle with the largest area which
What's the most efficient way to concatenate strings?
What's the most efficient way to resize large images in PHP? I'm currently using
What is the most efficient way to determine how many comments a particular blog
What's the most efficient way to convert the output of this function from a
What is the most efficient, secure way to pipe the contents of a postgresSQL
Whats the most efficient way of selecting total number of records from a large
What would be the most efficient way of recording to a log (.txt) from
What is the most efficient way to get the default constructor (i.e. instance constructor
What is the most efficient way of turning the list of values of a

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.