Domanda

I know this poses a security risk, but I was just wondering out of principle; is storing some non-sensitive, constantly accessed data in a file (On the same server) quicker than pulling this information every time from the database?

È stato utile?

Soluzione

The answer depends on a variety of different aspects. To name a view:

  • Is the data that's being fetched from the database easily accessible? That is, are the queries needed to generate the answer optimized (indexes, query caching possible)?
  • Are you postproccessing the data after pulling it from the database? If so, is it possible to cache the outcome or impossible due to some kind of dynamic properties (e.g. a monetary value that needs to be translated to another currency with real time excachange rates)?
  • Assuming you are going to cache the data in a file, is it possible to write it to an in-memory filesystem rather than constantly hitting the disk.
  • How often do these data change? Regularly? Ever so often?

All these (and a couple of more once you start thinking) aspects you would have to take into consideration.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top