The UI Blues

August 14, 2004 at 3:58 pm Leave a comment

Working on a User Interface is enough to give anyone the blues… Designing the screen layout isn’t easy, and once you do know what you want it to look like, you have to figure out all the fancy SQL statements needed to be able to display the data.

Once you have the SQL statements figured out, you really run into a quandry, unless you have an extremely simple application. To produce a single page of HTML, you may end up with multiple queries per category. So, do you run the risk of performing 30 SQL queries per page-load? There has got to be a better way!

In my case, the better way has involved loading all category data into memory, then iterating through that data to determine sub-category relationships, etc. as needed, instead of performing a SQL query per category to figure that out. This “caching” of data isn’t that difficult, but does move you away from a “pure SQL” mode of thinking. I still have to perform one query per visible category to get a count of all questions in that category and the below sub-categories, but that was expected. Still, this should reduce the number of SQL queries per page-load to about 50% of what it would be otherwise.

Now, you might think that cutting out a query here and there isn’t that big of a deal, but it really is… Anyone who has every been Slashdotted will agree with me on this one. If you suddenly have 10,000 people all trying to hit your page within seconds of each other, your server will be much happier with more efficient code, since it will have to perform the code for each and every request.


Entry filed under: PHP.

Image Optimization An Important Programming Truth, re-discovered

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


August 2004
« Jul   Sep »

Most Recent Posts

%d bloggers like this: