• punsaonline (5/19/2009)


    Hi,

    My Query previously looks like that

    Select A.A1,B.B2

    FROM A_TABLE A

    INNER JOIN B_TABLE B

    ON A.A1 = B.B1

    WHERE B.B2 = 'XYZ'

    This query executed in seconds but when i changed this query to

    Select A.A1,B.B2

    FROM A_TABLE A

    INNER JOIN (SELECT B1,B2 FROM B_TABLE

    WHERE B2 = 'XYZ'

    )B

    ON A.A1 = B.B1

    then this query takes more than an hour. It's wired but i don't know the reason. Please help.

    Does the first query return the expected result set?

    You might want to look at the actual execution plan for both queries and see if there is a difference. I wouldn't be surprised if they are different.