Results 1 to 4 of 4

Thread: fasten the search on large table

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2008
    Posts
    21

    fasten the search on large table

    Hi

    (SQL Server 2005)I have a huge table "Articles" that contains over than one million records and I need to fasten the search.
    the field of this table are:
    ArticleID int
    Title nvarchar(100)
    Author nvarchar(100)
    Filename varchar(50)
    KeywordID int
    ArticleDate datetime

    I usually search this table by its Filename and/or KeywordID and/or ArticleDate
    so i thought i should add indexes on those fields but i don't know what type of indexes should I add and how.

    Could anyone give me an example?

    thanks

  2. #2
    Member
    Join Date
    Jan 2007
    Location
    Bacau - Romania
    Posts
    53

    Re: fasten the search on large table

    You can do this with SQL Server Studio Management, or you can execute this code:

    Code:
    IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Articles]') AND name = N'index')
    CREATE NONCLUSTERED INDEX [index] ON [dbo].[Articles] 
    (
    	[Filename] ASC,
    	[KeywordID] ASC,
    	[ArticleDate] ASC
    )WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
    If you set these columns as indexes, the search will be much faster, if you search by these fields.

  3. #3
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: fasten the search on large table

    The search will be faster with indexes yes. But if you are going to use wildcard searchs with the wildcard before the name such as anything with the word House in the filename (Where Filename Like '%House' you will not use the indexes and resort to table scanss
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  4. #4
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: fasten the search on large table

    If you are not using Stored Procedures yet then using one would help in speeding up your queries.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width