Index of MySQL database Optimization Technology

Source: Internet
Author: User
  • eq_ref

    one row will be read from this table for each combination of rows from the previous tables. other than the const types, this is the best possible join type. it is used when all parts of an index are used by the join and the index is a Primary Key or unique index.

    eq_ref can be used for indexed columns that are compared using the = operator. the comparison value can be a constant or an expression that uses columns from tables that are read before this table.

    in the following examples, MySQL can use an eq_ref join to Process ref_table :

     select * from  ref_table ,  other_table  where  ref_table .  key_column  =  other_table .  column ; select * from  ref_table ,  other_table  where  ref_table .  key_column_part1  =  other_table .  column  and  ref_table .  key_column_part2  = 1; 
  • Ref

    All rows with matching index values will be read from this table for each combination of rows from the previous tables.RefIs used if the join uses only a leftmost prefix of the key or if the key is notPrimary KeyOrUniqueIndex (in other words, if the join cannot select a single row based on the key value). If the key that is used matches only a few rows, this is a good join type.

    RefCan be used for indexed columns that are compared using=Operator.

    In the following examples, MySQL can useRefJoin to processRef_table:

    Select * fromRef_tableWhereKey_column=Expr; Select * fromRef_table,Other_tableWhereRef_table.Key_column=Other_table.Column; Select * fromRef_table,Other_tableWhereRef_table.Key_column_part1=Other_table.ColumnAndRef_table.Key_column_part2= 1;
  • Ref_or_null

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.