Optimizing Query

  • Hi Everybody..

    I have a table which has 1 million records in it i am doing a select on that table with a where condition it is taking a very long time as 1:45 mins it takes to get me 28259 record...

    Question : How can i reduce the exection time..

    Code: Select * from TempReport Where DATETIMELASTMODIFIED Between '06/23/2005' And '08/22/2005' And IDLocation='{2D93FD6E-64F7-4A0A-A7F9-0B806D8907ED}'

    Note: I have no UNIQUE field in it so no field is indexed ..

    Thanks in advance

    Arun karthik

     

     

     

     

  • Hi Arun,

     

    Create a covered index on

    DATETIMELASTMODIFIED , IDLocation columns and executre the query.

    Script to create index

     

    Create NonClustered index IX_DATE_ID ON TempReport (DATETIMELASTMODIFIED ,IDLocation )

     

    Reagrds,

    ramesh

  • Also try to change the IDLocation data type to be an INT (wich should cover your location) but will MUCH faster than have UniqueIdentifier

    IDLocation='{2D93FD6E-64F7-4A0A-A7F9-0B806D8907ED}'


    Kindest Regards,

    Vasc

  • quote Note: I have no UNIQUE field in it so no field is indexed ..

    Not every index has to be based on unique set of fields, only Unique Index.

    Check this link:

    Creating Index

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

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