TSQL query taking too long

  • I have a table, with nvarchar(50) of 40 million records, this field has an unique index on it

    The table itself has an id field, which is the primary key, and is identity

    But

    my query is

    Select count(*) from table where not thedate is null

    The table does have a non unique index on thedate already, the query is taking 15 minutes plus and i cancelled it.

    My ram situation could be an issue, im only giving SQL Server 1.8 gigs of ram, since my system alone only has 3.0 gigs

    Anyone know how i can get fast results from this table, i mean i have an index on the field. Is it the fact i allowed nulls?

  • Try:

    Select count(thedate) from table where thedate is not null

    see if that helps.

    Other than that look at the execution plan, the IO statistics (SET STATISTICS IO ON), performance monitor, profiler...

  • Please don't cross post, reply here.

    Mohit.

    [font="Arial"]---

    Mohit K. Gupta, MCITP: Database Administrator (2005), My Blog, Twitter: @SQLCAN[/url].
    Microsoft FTE - SQL Server PFE

    * Some time its the search that counts, not the finding...
    * I didn't think so, but if I was wrong, I was wrong. I'd rather do something, and make a mistake than be frightened and be doing nothing. :smooooth:[/font]

    How to ask for help .. Read Best Practices here[/url].

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

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