Hoytman
Hoytman

Reputation: 1812

Database or file record keeping - php

I am creating a record system for my site which will track users and how they interact with my site's pages. This system will record button clicks, page view times, and the method used to navigate away from a page (among other things.) I an considering one of two options:

  1. create a log file and append a string to it for each action.
  2. create a database table and save entries based on user interaction.

Although I am sure that both methods could easily fill my needs, which would be better in the long run. Other considerations:

  1. General page viewing will never cause this data to be read (only added to it.)
  2. Old Data should be archived, but still accessible.
  3. Data will be viewed and searched via web app

Upvotes: 0

Views: 349

Answers (2)

Jerbot
Jerbot

Reputation: 1168

As with most performance questions, the answer is 'It depends.'

I would expect it depends on the file system, media type, and operating system of your server.

I don't believe I've ever experienced performance differences INSERTing data into a large, or a small MySQL database. The performance differences manifest when you retrieve that data. The database will almost always outperform queries to files, especially when you want complex or statistical data.

If you are only concerned with the speed of inserting/appending data, and expect a large amount of traffic, build a mock environment and benchmark each approach. If you want to have any amount of speed retrieving that data in a structured way, go with the database.

Upvotes: 1

SQL.injection
SQL.injection

Reputation: 2647

If you want performance you should inspect the server log, instead of trying to build your log system...

Upvotes: 0

Related Questions