English 中文(简体)
采用MySQL指数的情况?
原标题:Example Use of MySQL Indexes?

我正在阅读关于这4国之间差异的问题:。 INDEX、PRIMaire、UNI Request、FULLTEXT in MySQL?

然而,在阅读后,这完全是抽象和模糊的。 如果我有一些例子说明我何时使用它的话,这或许会有助于我更具体地理解。

例如,我想到外地<代码>用户_id,我们将使用索引UNI Request,正确?

问题回答

A primary key is not an index, per se --it s a constraint.
The primary key uniquely identifies a row from all the rest - that means the values must be unique. A primary key is typically made of one column, but can be made of more than one - multiple columns are called a composite....

缩略语作为指数在MySQL中实施,它保证,在定义的栏目中不会出现相同价值。 一个独特的制约因素/指数在主要一栏中是多余的,一个主要的关键可以视为同义词,但具有更大的影响。 这些支助综合体......

在MySQL(和服务器)中,有两种类型的indexes - clustered and non-clustered。 集群指数通常与主要钥匙有关,如果在<代码>CREATE TABLE上界定了主要关键因素,则自动生成。 但是,这并不必要——它是一个表上最重要的指数,这样,如果它能更优化地与不同的栏目挂钩,那么应该审查这一变化。 表格只能有一个分类索引,其余是非分类索引。 您界定指数的空间数量取决于表发动机——。 指数是非组别的,用于加快数据检索速度,其使用可以通过按照条款使用SélectT、JOIN、WHERE和ORDER的栏目启动。 但是,由于保留了这一数据,它们还延缓了INSERT/UPDATE/DELETE声明。

<>完整> 文本索引明确用于全文检索功能,没有其他功能可加以利用。 仅限用以数据类型界定的栏目。

http://em>not。 ANSI——这种相似之处令人欣慰地相对一致。 甲骨质的指数是相同的。

此处简要介绍它们现在和何时使用:

  • INDEX: To speed up searches for values in this column.
  • UNIQUE: When you want to constrain the column to only contain unique values. This also adds an index. Example: if you only want each email to be registered once, you can add a unique constraint on the email column.
  • PRIMARY KEY: Contains the identity for each row. A primary key also implies a unique index and a "not null" constraint. It is often an auto-increment id, but it could also be a natural key. It is generally a good idea to create a primary key for each table, although it is not required.
  • FULL TEXT: This is a special type of index that allows you to perform searches for text strings much faster than LIKE %foo% .

请注意,我只考虑这里的单列索引。 也可以有一个多科指数。

1. 如果您有一张贴现、姓名、电子邮件和生物信息的“个人”表格。

  • The primary key is the id, maybe it s a number it will allways be unique and you could use it as a reference in other tables (foreign keys)
  • the email is unique on each person, so you could add a UNIQUE constraint there
  • you might want to search a person over his name constantly so you could add an INDEX there
  • and finally a full text search in the bio attribute because it might be useful on a search

主要钥匙也是UNIquest。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签