Creating Multiple indexes in one SQL statement

  • Hi, I need to create 3 separate indexes on a very large database table.  I have the code :

    CREATE  INDEX shgidx_MPVEVisitType ON MriPatientVisitEvents (VisitType) WITH  FILLFACTOR = 90 ON [PRIMARY]

    GO

    CREATE  INDEX shgidx_MPVEVisitDateTime ON MriPatientVisitEvents (VisitDateTime) WITH  FILLFACTOR = 90 ON [PRIMARY]

    GO

    CREATE  INDEX shgidx_MPVEVisitAccountNumber ON MriPatientVisitEvents (VisitAccountNumber) WITH  FILLFACTOR = 90 ON [PRIMARY]

    GO

    Can I make this run faster?  Is there a way to create all 3 at the same time running the query once? 

     

    thanks,

     

  • You'll need 3 statements to perform this action

    - one way to speed it up might be to put your indexes on another disk as the rest of your data.

    - maybe (depending on the available size of tempdb) you can use sort_in_tempdb parameter to make it go faster a create/maintenance time. Check BOL

    CREATE  INDEX shgidx_MPVEVisitType ON MriPatientVisitEvents (VisitType) WITH  (FILLFACTOR = 90 , SORT_IN_TEMPDB = ON ) ON [PRIMARY]

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • > Is there a way to create all 3 at the same time running the query once?

    To create an index SQL Server needs to scan all values in the column(s).

    The only point to have index is to avoid scans.

    So I don't see any point of creating index(es) on fly.

    Do you?

    _____________
    Code for TallyGenerator

  • I think that she needs help on the fact that building a single index on a very large table takes a lot of time VS a course on why to build indexes.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply