Welcome Guest, Not a member yet? Register   Sign In
Creating Search Engine Friendly URLs
#11

[eluser]Mikle[/eluser]
[quote author="Dam1an" date="1250799474"][quote author="Mikle" date="1250797308"]And how about perfomance if there are 2000+ posts in blog?[/quote]

It's not going to be a problem, even without an index
I'm doing lookups by slug on a table with 70,000+ rows and there's no added delay compared to ID lookups[/quote]
And how about md5($slug)?
#12

[eluser]richthegeek[/eluser]
Mikle, and ajushi; the VARCHAR column type is properly expanded to "variable characters" - that is, the actual field size (and thus index size) is equivalent to the length of the entry.

You would store the MD5 in a CHAR(40) or VARCHAR(40) column, and each entry would always be 40 characters long.

Frankly though its unimportant, since any good sorting algorithm would only consider as many chars as are needed to place an item within a list (Apple and Anaconda would only test the first two, for example) so the actual length of the string is only an issue when you have two very similar strings (Apple and Apply) of large length.
#13

[eluser]Johan André[/eluser]
[quote author="Mikle" date="1250799721"][quote author="Dam1an" date="1250799474"][quote author="Mikle" date="1250797308"]And how about perfomance if there are 2000+ posts in blog?[/quote]

It's not going to be a problem, even without an index
I'm doing lookups by slug on a table with 70,000+ rows and there's no added delay compared to ID lookups[/quote]
And how about md5($slug)?[/quote]

Sure MD5 is an option.
#14

[eluser]Mikle[/eluser]
[quote author="richthegeek" date="1250801598"]Mikle, and ajushi; the VARCHAR column type is properly expanded to "variable characters" - that is, the actual field size (and thus index size) is equivalent to the length of the entry.

You would store the MD5 in a CHAR(40) or VARCHAR(40) column, and each entry would always be 40 characters long.

Frankly though its unimportant, since any good sorting algorithm would only consider as many chars as are needed to place an item within a list (Apple and Anaconda would only test the first two, for example) so the actual length of the string is only an issue when you have two very similar strings (Apple and Apply) of large length.[/quote]

40 chars & 140 chars is a big difference on many records. On my construction portal 2000+ articles and titles 80-150 chars.
#15

[eluser]richthegeek[/eluser]
Mikle - column length makes no difference on sorting, as only the first few characters are ever compared. MD5'ing an entry, I would imagine, would increase the occurences where a large number of characters are compared.
#16

[eluser]Mikle[/eluser]
[quote author="richthegeek" date="1250835066"]Mikle - column length makes no difference on sorting, as only the first few characters are ever compared. MD5'ing an entry, I would imagine, would increase the occurences where a large number of characters are compared.[/quote]

And save storage space on hdd.
#17

[eluser]mattpointblank[/eluser]
In my URLs, I just append the ID after the slug, eg:

site.com/article/category/slug/123

Then if I ever need to rewrite my links (say we rename an article, or category) the link will still work:

site.com/article/news/obama-wins-election/123
is the same as
site.com/article/latestnews/new-president-elected/123

A bit more future proof I guess by linking articles to something that will definitely not change.
#18

[eluser]Mikle[/eluser]
[quote author="mattpointblank" date="1250873388"]In my URLs, I just append the ID after the slug, eg:

site.com/article/category/slug/123

Then if I ever need to rewrite my links (say we rename an article, or category) the link will still work:

site.com/article/news/obama-wins-election/123
is the same as
site.com/article/latestnews/new-president-elected/123

A bit more future proof I guess by linking articles to something that will definitely not change.[/quote]

And if user go to url:
site.com/article/news/obama-wins-election/

you should return 404 page




Theme © iAndrew 2016 - Forum software by © MyBB