Monday, March 12, 2012

Indexing - What is fastest? Numeric or Alpha fields?

If I create an index on a field in SQL Server, what will be the most efficient (fastest) field type to index a field? (This field will be a "Pointer" to a child table that will contain a list of codes, and their description.)

Would a Numeric field be quicker than a VarChar field?

VarChar would make it easier for a Human to decipher the raw records. (For example, if I used a numeric the code would be 42 or 47, while the VarChar could be'savings' or'checking'.)

Basically I will have the following "Master" table:

FieldType---IDIntNameVarCharStatusInt -or- VarCharCustomer_TypeInt -or- VarChar

If Customer_Type is a code that can be looked up in another table, and I index that field, would I want the "Code" to be an Int or VarChar?

SQL:

Select *From MasterWhere Customer_Type = <42> or <'savings'>

MyWhereclause would depend on the field type.

Thank you,
Bryan

Int.

No comments:

Post a Comment