Page 1 of 1

Building a table of constants

Posted: Wed Sep 10, 2003 10:23 am
by David McWilliams
All of my pages refer to a 20x100 table of "constant" data, with each page using a few rows or columns. I am looking for the most efficient way to store this table.

I've come up with a couple obvious ways, but they both have drawbacks. I'm hoping someone more experienced could point to a better way.


Method 1: Create an include file, where I build the table using arrays.
+Only one line of code required to get full access to the table.
-Must build the 2000-cell table every time a page loads.

Method 2: Store the table in an SQL database.
+Only loads the needed rows or columns, reducing execution time.
-Must create custom SQL lookup code for every page.


Is there really a big speed difference between these two solutions? Is there a better solution?

-David McWilliams

Posted: Wed Sep 10, 2003 11:20 am
by xisle
i would decide based on how often the data needs to be
updated and how much traffic we are talking about....

1. rarely updated: build the flat file once and
include it into the page
2. occasionally updated: store in a sql database, provide editing tools, and build out a flat include file whenever the data is updated.
3. frequently updated: store in a sql database and build page dynamically every time. Unless we are talking thousands of hits a day, than use method 2.

my 2cents :wink: