?
Solved

creating index tables sql server 2005

Posted on 2007-03-26
7
Medium Priority
?
153 Views
Last Modified: 2010-03-19
how do you create index to your tables? for sql server 2005 server
0
Comment
Question by:gianitoo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18792807
in short, TSQL:
CREATE INDEX <indexname> ON <tablename> ( <column list>)

in the table design, or table menu context you find the manage indexes to do it using GUI.

note that for big tabes, creating the index can take some time ...
0
 
LVL 7

Expert Comment

by:Jonathan Kelly
ID: 18792815
you can use the client tools
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=C243A5AE-4BD1-4E3D-94B8-5A0F62BF7796

or you can use TSQL to alter your tables.

give more detail about your situation.
0
 
LVL 1

Author Comment

by:gianitoo
ID: 18792831
i just have a simple table.  want to make sure it is indexed so it can run faster when the table begins to grow.  it will be for a future survey and last time we had 500,000 hits and start running slower.

USE [JMI]
GO
/****** Object:  Table [dbo].[vote]    Script Date: 03/26/2007 10:05:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[vote](
      [ID] [int] IDENTITY(1,1) NOT NULL,
      [voteid] [int] NULL,
      [Email] [varchar](max) NULL,
 CONSTRAINT [PK_vote] PRIMARY KEY CLUSTERED
(
      [ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 18792895
>want to make sure it is indexed so it can run faster
simply adding index(es) is not the good way to proceed.
you have to identify WHICH queries will run on the table, and by that means add indexes if needed.

note: the primary key field is indexed automatically!

now, looking at the table, I assume that you will search for voteid or by email, and you might want to have that index clustered instead of the primary key one...
0
 
LVL 1

Author Comment

by:gianitoo
ID: 18792931
on that table the query that will run will look for voteid.   how can i make it so it performs better?

what would you do?

for instance this is the query that i am concerned about.  when we had 500,000 votes then it created an issue.

      SELECT     TOP (6) COUNT(vote.voteid) AS ['Count Of Teams'], racerinfo.racername, CAST(COUNT(vote.voteid) AS real) /
                          (SELECT     CAST(COUNT(voteid) AS real) AS Expr1
                            FROM          vote) * 100 AS TotalPercentage
FROM         vote INNER JOIN
                      racerinfo ON vote.voteid = racerinfo.ID
GROUP BY racerinfo.racername, vote.voteid
ORDER BY ['Count Of Teams'] DESC
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18793112
as I said, create a clustered index on the voteid field, and remove the clustered keyword from the table PRIMARY key.
0
 
LVL 1

Author Comment

by:gianitoo
ID: 18793175
thanks angel.  
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question