Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 14th, 2002, 08:39 AM
VSTi VSTi is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Posts: 2 VSTi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Resource usage - SQL Query vs Include file

I’m interested to see what people think about this, hopefully this is the correct forum as the server is Apache running on Linux:

My news page gets around 5000 views a day but is currently in a basic HTML file that I update with the latest news. I’m going to add it to a database to improve functionality so the news will be stored in a MySQL database, but what would be the least resource intensive on a server:

Running an SQL query to generate the latest news every time someone visits the page or Including a file into the page every time someone visits the page. (i.e when news is updated in the database an include file is automatically updated). Bare in mind my adverts serving script is also PHP/MySQL so this is already on every page.

The include file would be around 10 - 15k, the query would be less as it would only contain the news data and not the HTML to format it as that would already be in the news page.

My server is already worked quite hard and I need to move to a more powerful one really but for now I’d like to be as gentle on it as possible, I haven’t got a clue if the I/O required to include the file would be any less resource intensive than running the SQL query.


Cheers
Ben

Reply With Quote
  #2  
Old February 14th, 2002, 08:49 AM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,635 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 44 m 19 sec
Reputation Power: 77
Send a message via AIM to Hero Zzyzzx
Minimizing SQL queries and optimizing those that you have to run is almost always the best place to save on speed in any web application.

Basically, the fewer SQL queries you run the better, but if you're already incurring the overhead of connecting to MySQL because of your ads then the penalty isn't as great.

My gut tells me that pre-creating your HTML file and including it is going to be significantly faster, even if you're still running a query or two to create your pages.

Of course, the only way to know is to benchmark! Make your full-SQL system and benchmark that with ab (apache benchmark, included with apache) and then try your "include" system.

This should probably be posted in the PHP forum, or maybe even Lounge because it's a general "efficiency" question.

Reply With Quote
  #3  
Old February 15th, 2002, 06:46 AM
VSTi VSTi is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2002
Posts: 2 VSTi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile

Thanks for your reply Hero, I'll investigate Apache Benchmark and see what the results are.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > Resource usage - SQL Query vs Include file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT