• Creator
    Topic
  • #10374
    david.h
    Participant

    Hi Anh,

    I would like to add some SQL indexes to MetaBox custom tables, what is the best way to achieve that?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #10384
    Anh Tran
    Keymaster

    Hi David,

    When you create a table, you can set which column(s) are indexed. Just put the columns you want to index in the last param of MB_Custom_Table_API::create function.

    For example, this code will index the column email:

    MB_Custom_Table_API::create( 'my_custom_table', array(
        'address' => 'TEXT NOT NULL',
        'phone'   => 'TEXT NOT NULL',
        'email'   => 'VARCHAR(20) NOT NULL',
    ), array( 'email' ) );

    See the docs for more info.

    If you want to do that manually with raw SQL, you can do that via a tool like phpMyAdmin.

    #10387
    david.h
    Participant

    Hi Anh,

    The MetaBox API won’t work for my needs, see example:

    http://www.unofficialmysqlguide.com/covering-indexes.html

    I’ll add the index manually.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Covering indexes’ is closed to new replies.