Forum Moderators: open

Message Too Old, No Replies

mysql search optimization trick

is my trick any good?

         

moshebar

11:37 pm on Feb 12, 2009 (gmt 0)

10+ Year Member



hey,
i have a table with 200,000 records (won't change size anymore), with a varchar 150 (indexed) field in it, containing a specific string .
i want to add an integer field, name First_Letter_Of_String, which will numericly encode the first letter of each record,
e.g:
A=>1,B=>2,....,Z=>26

so if a record contains a field with a value "a test value",
the value of First_letter_of_string would be 1.

that way, when someone searches for "zebra" i will run the query:
"select * from table where first_letter_of_string=26 and string_field like 'zebra%';"

is this faster than the usual "select * from table where string_field like 'zebra%" ?

or does mysql do any key optimizations (which i expect from him :) so i won't have to make this optimization "patch" myself ?

thankl

topr8

10:20 am on Feb 13, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



set a full text index on the field,

but why don't you test to see if your method is any good, use the MySQL query browser to see how long your queries take and if your idea is quicker or not!