views:

68

answers:

6

Building a form, I'm wondering if there is any significant advantage to having the query string show values in a more human readable format.

example index.php?user=ted&location=newyork&...and so on

rather than index.php?user=23423&location=34645&... and so on

On the one hand, having the query string a little more readable allows the user and search engines (?) to better understand where they are, but this also creates a little more work on the server side, as I'll have to track down the associated rows through something other than their unique id.

i.e., first find what the id of 'newyork' is before being able to work on other rows that require the location_id. I always prefer to give the db as little work as possible.

edit: decided to go with readability. I figure I can always use the mysql query cache to speed things up if necessary.

+1  A: 

Use human readable values when you can. Just be sure to sanitise the input.

Edit: Yes, this can and should still be done for SEO purposes (if its worth it to you) if you have lots of choices. Even if the user has lots of choices, you should know what they are (or what the limits are) so that you can properly sanitise the input. For instance, if they are choosing states, you can know all 50. If they are just making up their own text, make sure on your end that its only text.

Citizen
Do you not think this will slow things down when there are a lot of values? Let's say I have 15 values in the query string. I could potentially need to look up ids for 15 of those values (probably not, but you see what I'm getting at). That's a lot of overhead. Maybe I should be looking at reworking how my database is set up.
Brad
If you have that many values, then I'd consider using a post unless you REALLY need them in the URL.
jeffa00
Once you get that many values in the URL it isn't human readable any way...
jeffa00
You should always know the limits of the choices your users can make. Whether its full text or number based, it shouldn't matter if you're sanitizing properly.
Citizen
And if this is the next question, whatever you do it should be stored via ID and not the text value if there's a choice. Use the text value only for displaying, not storing.
Citizen
A: 

A good rule of thumb is to store data as id's and display it as human readable text etc.

Robert Greiner
A: 

Depends on your goals.

If you are talking about something like a blog where you want everyone to see everthing (and find it easily), then the human/search engine readable format is a no brainer.

If these pages are locked behind a login then it doesn't much matter. You can do what is easier on the database.

For most internet apps, I'd err to the side of readability since that will help with search engines as well.

jeffa00
It's part of a search form where anyone can search for products. At present the form has about 10 different options to search with, but more will be added in an 'advanced' search.
Brad
A: 

You shouldn't worry about the efficiency for any typically sized application on any reasonable database engine. Write your app for users, not for query optimizers. QO's can more easily take care of themselves. Deal with optimization in the unlikely event you start seeing a problem.

le dorfier
A: 

I am going to come from a different direction. In my opinion a URL should be readable if want the user to be able to use the URL to change their parameters by editing the URL instead of using the UI. An example would be https://www.coolreportingapp.com/accountReport.jsp?account=ABC&month=200911 . In this example, the user can "easily" change the account or month they looking at without messing with the UI. This of course means you need to validate the URL params each and every time, which you should do anyway. If you don't want the user to alter the URL params, you need to obfuscate and hash values and use the hash to verify they haven't.

Jay
A: 

Seriously, IMHO, in your example, none is more readable than the other. Do normal users know that "&" is a separator from "variables" in "user=ted&location=newyork&"? Do they need to know that exists something like a variable? Having this in mind, what's the difference in showing numbers or words?

If you really want readable urls you should build SEO Friendly urls (human readable). Remember that even a "dashes vs underscores" simple question matters in the end.

GmonC