mysql database and php reading

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
spamyboy
Forum Contributor
Posts: 266
Joined: Sun Nov 06, 2005 11:29 am
Location: Lithuania, vilnius

mysql database and php reading

Post by spamyboy »

I'm creating a dictionary script for my website and I'm just poundering, what if I would split all words by theyr first letter to difrent tables, would that optimise page loading ?
for e.g. if person searches for somekinde of word, script would take search query first letter and only then parse data from database.
Would that be better or I have missed anything while thinking?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

keep them all in the same table. As long as you create the neccesary keys it should be fine.
User avatar
spamyboy
Forum Contributor
Posts: 266
Joined: Sun Nov 06, 2005 11:29 am
Location: Lithuania, vilnius

Post by spamyboy »

by "neccesary keys" you mean ?, all I did is set PRIMARY ID and word as INDEX.
User avatar
nathanr
Forum Contributor
Posts: 200
Joined: Wed Jun 07, 2006 5:46 pm

Post by nathanr »

you can partial index in mysql as in add an index which only covers the first 2 chars for example.. however unless you running a live search via ajax then it's really of no consequence as you need to search for the whole word anyways.

probably the only way to speed things up is to make a unique index on the "word" column, then read it with a handle.
alternatively, have the whole table stored as a MEMORY table..
Post Reply