Solved

creating index tables sql server 2005

Posted on 2007-03-26
7
151 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
I have a large data set and a SSIS package. How can I load this file in multi threading?
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

733 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