I am desiging a new table that will potentially have 200K rows.
I would like to make sure that querys to this table are efficiant.
in the past I had always given a row a unique id in the assumption that this would result in an index:
CREATE TABLE [dbo].[Equipment](
[EquipID] [nchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[EquipDescription] [nchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Category] [nchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[id] [int] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
is this enough? , should I be setting a primary key.
If any one has suggestions please let them fly.
T-SQL, SQL2000,
You only get an index if you either create a primary key or explicitly create one. The indices that you need are determined by your queries, just having an index on a column does not make that query faster unless you are querying or joining on that column.
Indices are also not without cost, they make your database larger, and they increase the cost of modifying the table.
This article, although old seems to give a good overview of indices.
If you are going to do a bunch of work with databases getting a database textbook like Database Systems and reading it, will prove invaluable. Finding the most efficient arrangement of indices and queries is difficult, and trial and error is not a good way of trying to optimize queries.