Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-05-2012, 10:48 AM   PM User | #1
Jimmyborofan
New to the CF scene

 
Join Date: May 2008
Location: Milton Keynes
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
Jimmyborofan is an unknown quantity at this point
Flat file or SQL? - constant values

So I have a bit of a problem,

The application I am working is (atm) very SQL hungry , it is procedural and has no framework per say.

Each page at the moment is created dependant upon a query string and the page 'content' is in actual fact an iframe(Please dont make issues arounf this, the future version is a re-write for full OOP and server efficiency) but this issue will be a future problem too

I want to be able to link a help page (from an outside url) to the current page.

Now I really am looking for efficiency here and this is why I am umming and ahhring

The link can be looked up using a flat file, SQL or hardcoded into each page, the last option is out as it means a lot of extra work, so I am looking to a Flat file look up or a SQL query.

This application has thousands of page hits each day so even a small SQL query will have larger implications later on.

But would a flat file look up be any more efficient because relative to the application the number of help files is around 35, where as the number of pages is dynamic and is built using various methods.

So My question is this, if a server building a page adds the extra data to build the link, would it be more or less efficient than using a flat file look up to index the help file to a particular page.

Please also remember that if a page needs a help file it has to calculate this, so the page table would have the help file flag and the info to build the link. whereas a flat file would be a $key=>$value set up using the query string data to retrieve the link data.

All help appreciated
Jimmyborofan is offline   Reply With Quote
Old 11-05-2012, 07:52 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Of options, filesystem will always be better than a dbms. But, you are indicating a lookup style functionality (key => value pairs), so this to me warrants the use of a db. If you had a file for each option available without the need for a parse and store, then the filesystem will outperform for sure. But when you need to lookup something, search, limit, etc, than the DB is typically a better option.

Are you issuing thousands of queries due to the traffic itself, or is it due to the script executing excess queries? If its the latter, you should look at why its doing this. Set the goal to 1 query per script, and run from there. I have yet to be able to write a piece of software with only 1 query per script load in PHP, but I have managed to bring down the queries in a fully functional application to 3. 3 per load is pretty good; I personally wouldn't be too worried until you are seeing in the 20ish per page load (IMO its still too high, but I wouldn't be concerned). Also note that queries can be limited to the number of queries issued per hour per user. I don't see it set very often, but I recall seeing it once set at 20,000/h.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
Jimmyborofan (11-05-2012)
Old 11-05-2012, 09:40 PM   PM User | #3
Jimmyborofan
New to the CF scene

 
Join Date: May 2008
Location: Milton Keynes
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
Jimmyborofan is an unknown quantity at this point
Thanks for that its pretty much what I expected. The site is a high traffic site, not because of excess queries. I proposed various alternate solutions to using SQL, as I was requested. I basically created a quick test to time a looped query. file read, and by using variables already present in the page. Showing that the server load on a query by extending the query to include an extra two columns was not really all that much...

Thanks for the reply though it kinda confirmed my own thoughts.
Jimmyborofan is offline   Reply With Quote
Old 11-06-2012, 11:37 AM   PM User | #4
MarkR
New Coder

 
Join Date: Sep 2011
Posts: 80
Thanks: 0
Thanked 13 Times in 12 Posts
MarkR is an unknown quantity at this point
Are you using any form of local caching? There is no reason why common queries can't be cached for a few hours if results are unlikely to change for a long duration of time.
__________________
Web Design Newcastle
MarkR is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:15 PM.


Advertisement
Log in to turn off these ads.