You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by "Diethelm Guallar, Gonzalo" <Go...@sonda.com> on 2001/08/22 15:49:32 UTC

Wrong index generation?

In Turbine 2.1 (from cvs), a schema like this one:


<table name="SF_STF_OPERATOR">
 <column name="BRANCH_CODE" primaryKey="true" required="true"
type="INTEGER"></column>
 <column name="OPERATOR_CODE" primaryKey="true" required="true"
type="INTEGER"></column>
 <column name="LOGIN_NAME" required="false" type="VARCHAR"
size="32"></column>
 <column name="SIGNED_ON" required="false" type="BOOLEANINT"></column>
 <column name="DAY_OPEN" required="false" type="BOOLEANINT"></column>
</table>


is generating (for MySQL) a script like this one:


CREATE TABLE SF_STF_OPERATOR
(
    BRANCH_CODE INTEGER NOT NULL,
    OPERATOR_CODE INTEGER NOT NULL,
    LOGIN_NAME VARCHAR (32),
    SIGNED_ON INTEGER,
    DAY_OPEN INTEGER,
    PRIMARY KEY(BRANCH_CODE,OPERATOR_CODE),
    INDEX(OPERATOR_CODE)
);


Notice the index is only on OPERATOR_CODE, not on BRANCH_CODE and
OPERATOR_CODE, the two primary key fields. Is this intended?


-- 
Gonzalo A. Diethelm
gonzalo.diethelm@sonda.com

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Wrong index generation?

Posted by Daniel Rall <dl...@finemaltcoding.com>.
"Diethelm Guallar, Gonzalo" <Go...@sonda.com> writes:

> In Turbine 2.1 (from cvs), a schema like this one:
> 
> 
> <table name="SF_STF_OPERATOR">
>  <column name="BRANCH_CODE" primaryKey="true" required="true"
> type="INTEGER"></column>
>  <column name="OPERATOR_CODE" primaryKey="true" required="true"
> type="INTEGER"></column>
>  <column name="LOGIN_NAME" required="false" type="VARCHAR"
> size="32"></column>
>  <column name="SIGNED_ON" required="false" type="BOOLEANINT"></column>
>  <column name="DAY_OPEN" required="false" type="BOOLEANINT"></column>
> </table>
> 
> 
> is generating (for MySQL) a script like this one:
> 
> 
> CREATE TABLE SF_STF_OPERATOR
> (
>     BRANCH_CODE INTEGER NOT NULL,
>     OPERATOR_CODE INTEGER NOT NULL,
>     LOGIN_NAME VARCHAR (32),
>     SIGNED_ON INTEGER,
>     DAY_OPEN INTEGER,
>     PRIMARY KEY(BRANCH_CODE,OPERATOR_CODE),
>     INDEX(OPERATOR_CODE)
> );
> 
> 
> Notice the index is only on OPERATOR_CODE, not on BRANCH_CODE and
> OPERATOR_CODE, the two primary key fields. Is this intended?

Primary keys are implicitly indexed (at least, by both MySQL and
Oracle).  The additional index which is created is to provide faster
searching for the case when your WHERE clause contains only
OPERATOR_CODE.  See MySQL's documentation on the EXPLAIN command for
more information, or Table's doHeavyIndexing() method in
jakarta-turbine-torque.

                                Daniel

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org