Forum Replies Created

Viewing 15 posts - 6,196 through 6,210 (of 49,552 total)

  • RE: SELECT COUNT(*) vs DMVs to get row count

    sql-lover (4/11/2015)


    I decided I will use count with if exists.

    Count has no place in an IF EXISTS check. EXISTS doesn't care about the columns, hence why SELECT 1 is often...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: SELECT COUNT(*) vs DMVs to get row count

    sql-lover (4/11/2015)


    I am not looking for how many rows exactly I have on a table. I am looking for those tables without any rows.

    IF EXISTS (SELECT 1 FROM TableName)

    ...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: SELECT COUNT(*) vs DMVs to get row count

    Alan.B (4/10/2015)


    Ok, quick update... I did some research on this - it appears that sys.partitions does not guarantee an accurate row count. According to Microsoft, the rows column in sys.partitions...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: SELECT COUNT(*) vs DMVs to get row count

    jphillips 46546 (4/10/2015)


    Agree much less costly to just do a if exists (select top 1 from tablename)

    You don't need a TOP 1 in an EXISTS subquery.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: SELECT COUNT(*) vs DMVs to get row count

    Sean Lange (4/10/2015)


    sql-lover (4/10/2015)


    Is this an accurate way to get row count?

    SELECT

    t.name table_name,

    s.name schema_name,

    p.rows AS total_rows

    FROM sys.tables t

    join sys.schemas s on (t.schema_id = s.schema_id)

    join sys.partitions p on (t.object_id = p.object_id)

    WHERE...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: if inequality brings less rows and equality bring more , then can i put inequality as first col of index

    No, you want the equality first and inequality second and it does not depend on cardinality and distribution of the data.

    If you put the equality first and the inequality second,...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: sql Database (MDF) repair Best Tools

    A good backup.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Are the posted questions getting worse?

    Eirikur Eiriksson (4/11/2015)


    Does anyone have an idea on how to solve this problem?

    😎

    Extended events or the sys.dm_db_session_space_usage DMV which tracks tempDB usage per session (not per table, just overall space...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Are the posted questions getting worse?

    Luis Cazares (4/10/2015)


    Someone just mentioned that you could have 2 clustered indexes on a table. But I'm sure he's high. 😀

    http://www.sqlservercentral.com/Forums/FindPost1676220.aspx

    But, think about it, what if you're in situation where,...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Are the posted questions getting worse?

    Grant Fritchey (4/10/2015)


    Is everyone OK? Are people ill or something? Because this just happened and it has me concerned:

    Work deadlines and other stuff. Sorry, will do better next month

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Are the posted questions getting worse?

    SQLRNNR (4/10/2015)


    GilaMonster (4/10/2015)


    I love finding out that I'm giving a training course from the newsletter sent out the the entire company.

    That is awesome.

    I could use a few other phrases at...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: "normal" non-clustered index vs INCLUDE index

    RonKyle (4/10/2015)


    but by avoiding key lookups, or worse table/index scans

    assuming the table is not a heap (which it shouldn't be, right?), why would it (at least as a general rule)...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Error - an expression of non-boolean type specified in a context where a condition is expected , near ','

    Furthermore, you have a non-optimal query form.

    http://sqlinthewild.co.za/index.php/2009/03/19/catch-all-queries/

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: "normal" non-clustered index vs INCLUDE index

    simon_s (4/10/2015)


    Yes person_id is unique , role_id is not

    In that case they're pretty much going to behave much the same way for any query that filters on person_id. Use the...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: "normal" non-clustered index vs INCLUDE index

    Grant Fritchey (4/10/2015)


    RonKyle (4/10/2015)


    Interesting. I haven't personally made much use of include indexes since they do make the indexes bigger and I'm not convinced the performance gains are significant....

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 15 posts - 6,196 through 6,210 (of 49,552 total)