Indexing a database
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.
精彩评论