Linking Tables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • trevordixon@gmail.com

    #1

    Linking Tables

    Does linking tables with JOIN offer any significant performance
    advantage or does it just make things more simple from a programming
    standpoint?

    Trevor

  • don.orban@gmail.com

    #2
    Re: Linking Tables

    If you mean JOIN give you a performance boost compared to doing
    somethig lik "WHERE table_one_id = table_two_id" I'm not sure. You
    could always run "EXPLAIN {sql statement here}" to see if you see a
    difference.

    JOINS are necessary when you want to include everything from one table,
    even if it's not in the other (outer join).

    HTH
    D.

    trevordixon@gma il.com wrote:
    Does linking tables with JOIN offer any significant performance
    advantage or does it just make things more simple from a programming
    standpoint?
    >
    Trevor

    Comment

    • Bill Karwin

      #3
      Re: Linking Tables

      trevordixon@gma il.com wrote:
      Does linking tables with JOIN offer any significant performance
      advantage or does it just make things more simple from a programming
      standpoint?
      SQL89-style joins (SELECT * FROM table1, table2 WHERE ...condition... )
      and SQL92-style joins (SELECT * FROM table1 JOIN table2 ON
      ....condition.. .) should optimize identically in virtually all cases.

      I prefer the SQL92-style joins, because it includes syntax to do outer
      joins. There is no syntax to do outer joins in SQL89. It's nice to use
      one syntax style throughout one's app.

      Regards,
      Bill K.

      Comment

      • Thomas Bartkus

        #4
        Re: Linking Tables

        <trevordixon@gm ail.comwrote in message
        news:1154360543 .614627.80830@i 3g2000cwc.googl egroups.com...
        Does linking tables with JOIN offer any significant performance
        advantage or does it just make things more simple from a programming
        standpoint?
        >
        MySQL and other databases are *highly optimized* to do JOINs efficiently.

        I would turn your question around a bit and say there are no performance
        *disadvantages* to using JOINs with lots of great programming reasons to
        take advantage of them.

        The excuses people make to avoid learning table JOINs !

        Of these, the lamest is an unwillingness to take a performance hit involved
        with using JOIN. What performance hit? These amateurs take a performance
        hit bigtime in lousy database design that always results from JOIN
        avoidance.

        JOINS are your friend ;-)
        Thomas Bartkus


        Comment

        • trevordixon@gmail.com

          #5
          Re: Linking Tables

          Thanks to all, I'll certainly take advantage of joins in my project.
          They are certainly much better. I'm fairly new to MySQL, so I was using
          nested while loops on three different queries and it was taking 16
          seconds to perform about 900 queries on a page. Now by joining tables,
          it loads in two.

          Thanks again,
          Trevor

          Comment

          Working...