mysql optimizing table question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alex79
    Confirmed User
    • Jun 2002
    • 996

    #1

    mysql optimizing table question

    I have a table with next structure:

    Code:
    CREATE TABLE `table` (
    `keywords` TEXT NOT NULL
    ) TYPE = MYISAM ;
    where the rows are like:
    row1: keyword1,keyword2,keyword5,...
    row2: keyword10,keyword435,keyword5123,keywordn...


    i want to make selects like this:


    Code:
    select * from `table` where `keywords` like '%keyword2%'

    how do i optimize the `table` for a such selects? if i create an index on `keywords` column don't help becouse index are created after the firsts characters from column and are useful for selects with where `keywords` like 'keyword2%' not for selects with where `keywords` like '%keyword2%'

    How can optimize the table for a such select?
  • darksoul
    Confirmed User
    • Apr 2002
    • 4997

    #2
    http://dev.mysql.com/doc/mysql/en/Fulltext_Search.html
    1337 5y54|)m1n: 157717888
    BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
    Cambooth

    Comment

    • darksoul
      Confirmed User
      • Apr 2002
      • 4997

      #3
      also another option (fastest) would be
      table keywords (entry_id int auto_increment, keywords text, primary key(entry_id))
      table keywords_index (keyword varchar(16), simulated_array varchar(256))
      where simulated_array would reference table keywords
      its more work but its the fastest for search
      1337 5y54|)m1n: 157717888
      BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
      Cambooth

      Comment

      Working...