Reputation: 1333
I'm building a site that will link to various other sites using php scripts of the form website.php with the code in each file simply being:
header( 'Location: www.website.com' ) ;
I'm debating between two ways to create these files:
Option (2) has some advantages that I think are pretty important, but I'm afraid of performance issues -- i.e. will users see noticeable lag if all these links require a SQL query to get the redirect URL?
Basically, does anyone have experience using redirects that are pulled using a SQL query, and if so should I be concerned about slow performance?
Thanks!
Chris
Upvotes: 2
Views: 341
Reputation: 66012
I don't have specific experience with using values from SQL queries and passing them to header()
, but with SQL queries & php in general. In my experience, granted I've only done about two years of work in this area, SQL queries are not a performance issue. As long as your query doesn't require ninjaness to read/write/understand, then you should be fine. If the SQL query way has advantages, then go for it IMHO.
If you are that worried about it, run time tests on the queries you will be making and see what the results are.
Generally, all of the queries I do return sub-second.
I honestly don't believe that optimizing for performance is even necessary here.
If advantages come with the SQL way, then do it that way.
That's my two cents.
Upvotes: 1
Reputation: 33697
Both options are very fast, so maybe it's not even worth thinking about performance, when the database option has other advantages.
However, if you compare a static HTML file to a dynamic script that in addition executes a query, in hard numbers you will get a clear benefit with the static file (maybe something like 5 times the throughput and half the latency).
Not that anyone would notice anyway... ;)
Upvotes: 0
Reputation: 44161
I honestly don't think you are going to have much of a performance problem unless your site is getting pounded by thousands of hits at the same time. It's just one query and it will probably make things easier as your site grows and gets more complex. If it ever becomes a serious problem you could always look into using memcached
Upvotes: 0