Query Rewrite

  • Does developer champs have a better idea of rewriting this simple query. It takes 20+ seconds to execute becasuse it does a cartesian product. I want to get rid of the inner join.

    select a.compID, b.InitialRT, b.VwRgts, b.UpdRgts, b.InsRgts, b.delRgts, b.Sscrnum , c.UserID

    from tablecmpy a, tbldetrght b (nolock)

    inner join tableuser c (nolock) on c.GroupID = b.UserId

    where b.RecType='G'

    and b.compID='[ALL]'

    and b.InitialRT+b.VwRgts+b.UpdRgts+b.InsRgts+b.delRgts > 0

  • Post the DDL (CREATE TABLE statement) for the tables, sample data (INSERT INTO statements) for the tables, expected results based on the sample data, and the current execution plan (as a *.sqlplan file) for your current query.

    Thanks

  • Table "a" is not mentioned in any filter or join condition.

    Of course, every its row being applied to every record of the joined recordset of other 2 tables.

    Is it how it's intended?

    _____________
    Code for TallyGenerator

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

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