what keys should I use on my 3 way join?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • FFMG

    #1

    what keys should I use on my 3 way join?

    Given the query bellow, what keys would you create?

    SELECT
    t2.t1_a
    FROM
    table1 as t1,
    table2 as t2,
    table3 as t3
    WHERE
    t2.t2_b = t3.t3_b
    AND
    t2.t2_c = t3.t3_d
    AND
    t3.t3_e != 25
    AND
    t1_a = '3'
    AND
    t2_d ='0'
    ORDER BY en.t1_a DESC
    LIMIT 0, 15

    Thanks

    FFMG

  • Arjen

    #2
    Re: what keys should I use on my 3 way join?

    FFMG schreef:
    Given the query bellow, what keys would you create?
    >
    SELECT
    t2.t1_a
    FROM
    table1 as t1,
    table2 as t2,
    table3 as t3
    WHERE
    t2.t2_b = t3.t3_b
    AND
    t2.t2_c = t3.t3_d
    AND
    t3.t3_e != 25
    AND
    t1_a = '3'
    AND
    t2_d ='0'
    ORDER BY en.t1_a DESC
    LIMIT 0, 15
    Use the explain syntax

    http://dev.mysql.com/doc/refman/5.0/en/explain.html

    Good luck !

    Arjen

    Comment

    • universalbitmapper

      #3
      Re: what keys should I use on my 3 way join?


      FFMG wrote:
      Given the query bellow, what keys would you create?
      >
      SELECT
      t2.t1_a
      FROM
      table1 as t1,
      table2 as t2,
      table3 as t3
      WHERE
      t2.t2_b = t3.t3_b
      AND
      t2.t2_c = t3.t3_d
      AND
      t3.t3_e != 25
      AND
      t1_a = '3'
      AND
      t2_d ='0'
      ORDER BY en.t1_a DESC
      LIMIT 0, 15
      >
      Thanks
      >
      FFMG
      thanks Arjen for that link.
      Just in case a newbie read this, don't confuse a "key" as in relational
      model "primary key and foreign key", and an index.
      An index is a way to store rows physical adresses and data, in a way
      that an index block loaded in memory allows to quickly find physical
      rows related to that block.
      MySQL seems to encourage that confusion, as its use of the word key
      means: create an index on that primary key or foreign key.
      It's so strange that there is a strong possibility that I'm confusing
      things.
      What do you think?

      Comment

      Working...