开发者

Indexing a database

开发者 https://www.devze.com 2023-02-12 18:30 出处:网络
I want to index a db. But in most of the table foreign key constraints are not set.So b开发者_C百科efore start indexing whether we have to set the foreign key for all tables? Or just index the table c

I want to index a db. But in most of the table foreign key constraints are not set.So b开发者_C百科efore start indexing whether we have to set the foreign key for all tables? Or just index the table columns according to the queries.Please give your valuable suggestions.

Mahesh


Short Answer: Indexes do not rely on foreign keys or their constraints, foreign keys can enhanced by indexes though.. but indexes are often placed on columns that are NOT foreign keys.

Little detail: You should look at what you are searching for within your tables, and create indexes on those columns - but take that step seriously, indexing is a valuable process in database design, but can hurt you if done incorrectly.


Yes: Create Foreign Keys where the Domain requires them (i.e. all relationships to PK's). Even without indexes the optimiser will take these into account.

You can start by defining indexes on all FK columns, but it would be better to capture a representative query workload to determine your most expensive queries, and then index accordingly.

0

精彩评论

暂无评论...
验证码 换一张
取 消