refresh cache of mysql data I am creating a vb.net app that stores its data in mysql. There are
several lists of data that users access in drop down boxes and such.
The data does not change very much in the db. I was thinking that
when I needed to show one of these lists, I could check if there have
been any changes in the db first, if not I can just use the in-memory
data, saving the bandwidth of having to pull back an entire table. If
there has been a change, I can refresh the data with a call to the db.
pseudo code:
x = md5( in-memory list )
con.open
y = SELECT md5( sum of all rows in table ) FROM table;
con.close
if x = y then
'check sums are equal, no data changed, return in-memory data
else
'check sums are different, a change has been made, get new data
from table
con.open
dataset = SELECT * FROM table;
con.close
end if
The question is really: since i am opening a connection to the db when
checking the checksum, should I just bring back the table data since I
have a connection open and then check the differences in memory? Will
I save a bunch of performance if I do that preliminary check on the
db? Aren't I saving a bunch of bandwidth by not having to bring back
the whole table if the data has not changed? |