473,651 Members | 2,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

For best execution speed, should I cache in Main memory or keep querying the Database

vpawizard
66 New Member
Hello,
In my application, I need to read data of two sizes - about 10 bytes and 5-50KB. I need optimum performance of my application - speed is my main concern. Would it be wise to read 10 bytes from database and 5-50KB data from main memory(this data is read from database and cached in memory)?
Please suggest. Thanx in advance.
Jun 23 '07 #1
1 1426
pbmods
5,821 Recognized Expert Expert
Changed thread title to make it a little more descriptive.

Heya, vpawizard.

Ultimately, it is faster to cache results and serve them from memory. However, you want to be careful, because:
  • Caching results that you'll only need once wastes time and memory.
  • Caching results that are too large could result in out-of-memory errors.
  • Caching results only works if the data in the database remains the same. You'd have to be able to check to see if the data in the database has changed (keep in mind that you might have multiple instances of the app running on the same system in the case of a multi-User or webserver setup).

Many database servers already cache results. So if you run a query twice, and nothing has changed in the result set, the second query will execute almost instantaneously .
Jun 23 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
1851
by: Bob Bedford | last post by:
Sorry if I post here, but I don't have access to any valuable mysql ng for this question, ans since 99% or php programmers deal with mysql, I'm sure I'll get an answer here. Look at the folloming table: CREATE TABLE searchlog ( IDSearchLog MEDIUMINT UNSIGNED NOT NULL auto_increment, F1 MEDIUMINT UNSIGNED default NULL, F2 VARCHAR(40) default NULL, F3a SMALLINT UNSIGNED default NULL,
3
2279
by: I.V. Aprameya Rao | last post by:
Hi I have to implement a flat file dbms. The basic condition is that relations will be given in files and i will have to run certain select project join queries on those relations. Can someone tell me as to which language will be faster, python or C++?? Aprameya
2
1902
by: Tim | last post by:
I am doing a small asp webshop and want to make it atleast bi-lingual. I have thought of a few ways to do this but would like to have a second opinion on what you think is the best way. I have browsed the Google archives and seen this question pop up a few times before but never with any particulary good answers. For some reason this doesn't seem like a hot topic. I am not talking about the product information, that is already stored...
11
9240
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in C++. I find my self sometimes, trying Object app = Object(); Object *app = Object(); Object app = new Object();
3
3324
by: PWalker | last post by:
Hi, I have written code that I would like to optimize. I need to push it to the limit interms of speed as the accuracy of results are proportional to runtime. First off, would anyone know any resources that explains how to optimize code i.e. give some rules on c++ optimization? e.g. using memcpy to copy an array (which i have done). Also, what is the best sorting algorithm out there for sorting an array of of size 100 or less? I have...
16
4669
by: raj | last post by:
Hi, I saw it mentioned that "int" is the fastest data-type for use in C ,that is data storage/retrieval would be the fastest if I use int among the following 4 situations in a 32 bit machine with 4-byte ints: int m; bool m; // assuming I use C++ char m; unsigned char m;
26
6240
by: Ed L. | last post by:
Here's some of my current notions on pgsql performance tuning strictly as it relates to pgsql tuning parameters in the context of a dedicated linux or hpux server. I'm particularly focusing on the shared_buffers setting. I invite any corrective or confirming feedback. I realize there are many other hugely important performance factors outside this scope. One key aspect of pgsql performance tuning is to adjust the memory ...
24
5078
by: junky_fellow | last post by:
Hi, I read in some of the articles that there are two types of "reordering" of instructions. One at the compiler level and other at the processor/CPU level. What is the difference between these two ? How can a C programmer, prevent the reordering of instructions by compiler
13
2401
by: DigitalDave | last post by:
A project I did awhile back stored php5 objects in elements of the $_SESSION array between pages that were navigated on the site. There were object classes representing teachers, and object classes representing students that referenced teacher objects. Then I happened to look at the temporary files created by sessions and found much redundant data was stored in each file about the teachers since they were referenced by every student in...
0
8352
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8697
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8465
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7297
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5612
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4283
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2699
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.