You must Sign In to post a response.
  • Category: SQL Server

    Joining - Performance

    I have two tables.Table 1 have 1000 rows.Table 2 have 2000 rows.

    1) Table 1 JOIN Table 2
    2) Table 2 JOIN Table 1

    In above 2 steps, Which one is the best way to join in performance wise
  • #747262
    Hi,

    It depends on the data you require, if you want the complete data from Table 1 and matching rows from table 2 then use left outer join.
    Table 1 LEFT OUTER JOIN Table 2

    If it is revers way then use your second option.

    Let me know if I misunderstood your question.


    Regards,
    Asheej T K

  • #747264
    Thanks for your reply.
    I want 5 columns from table 1 and 5 columns from table 2

  • #747286
    Joins depend on the number of mapped columns. If there are too many joins it could prove counter productive. However number of rows should not affect the outcome, in terms of query performance.

  • #747360
    Hi,

    It's totally depends upon the relation between the tables. For ex table1 is master table and Table2 is child table then case 1 is correct.

    EX:

    select *
    from mastertable m,
    childtable c
    where m.col1=c.col1


    This will give faster performance...

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


  • Sign In to post your comments