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:
- Hardcode the URL for each website — basically nothing dynamic at all about the script.
- Use a SQL query to pull the URL from my site’s database then redirect to that URL.
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
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.