当前位置:网站首页>MySQL interview questions

MySQL interview questions

2022-06-24 13:24:00 Quinlan

mysql The scenario of index creation and the problem of index invalidation ?

MySQL The scenarios for indexing are

  1. Create an index for fields with high query frequency ;
  2. Sort 、 grouping 、 Index fields with high query frequency ;
  3. If you need to set multiple columns as indexes , You can use a multi column index
  4. Select a unique index and try to use an index with less data

The reason for index failure

1. Function parameters or expressions appear in the index column

Solution : Calculate the value of the expression in advance

2. Use left blur

Solution : Try to avoid

3. Use OR Some fields of the query have no index

Solution :or Add an index to the field

4. No single quotation marks

surface 1: Person

+-------------+---------+

| Name | type |

+-------------+---------+

| PersonId | int |

| FirstName | varchar |

| LastName | varchar |

+-------------+---------+

PersonId Is the primary key of the above table

surface 2: Address

+-------------+---------+

| Name | type |

+-------------+---------+

| AddressId | int |

| PersonId | int |

| City | varchar |

| State | varchar |

+-------------+---------+

AddressId Is the primary key of the above table

 

Write a SQL Inquire about , Meet the conditions : No matter what person Is there address information , Both need to be provided based on the above two tables  person For :

原网站

版权声明
本文为[Quinlan]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/05/20210522180817677R.html