I am using SchemaExport to automatically create our database, which has
a fairly simple structure (about 10 entities in total). The schema thus
created is perfect for our purposes, with one little nagging detail.
I have a many-to-one association from entity SDR to entity C. This forces
the creation of an index on a foreign key in SDR. This index is never used
(needed, actually) for the queries we have. Removing it manually even
speeds up the query a bit. Response time requirements are fullfilled
with or without the index, anyway.
SDR may have upto 64E6 rows, and C never has more than about 500.
The main problem, though, is that the index is very large - upto 10% of
total database size. And our space constraints are a bit more severe. For
that reason alone I would like to get rid of the index from the beginning.
I would prefer to be able, through the mappings, to tell SchemaExport
to not create the index - is there a way to do this?
(The various attributes on the many-to-one mapping do not seem to have
effect).
(The alternative is of course to export the DDL, modify it, and then
create the schemas with a script).
Thanks in advance for any help or hints,
Mike
Hibernate version: 3.0.5
Mapping documents:
I have shortened the names and removed extranous properties
for readability purposes.
For SDR:
Code:
<hibernate-mapping>
<class name="SDR" table="SDR" lazy="true">
<id name="id" type="long" column="id">
<generator class="native" />
</id>
<property name="numberOfDataRecords" />
<property name="numberOfUnplausibleData" />
<property name="minValue" type="float" />
<property name="maxValue" type="float" />
<property name="meanValue" type="float" />
<property name="rmsValue" type="float" />
<property name="standardDeviation" type="float" />
<many-to-one name="c" class="C"
column="C_ID" lazy="proxy" not-null="true"/>
<many-to-one name="ts" class="TS"
column="TS_ID" lazy="proxy" not-null="true" />
</class>
</hibernate-mapping>
For C:
Code:
<hibernate-mapping>
<class name="C" table="C" lazy="true">
<id name="id" type="long" column="id">
<generator class="native" />
</id>
<property name="name" not-null="true" />
<property name="unit" />
<many-to-one name="p" class="P"
column="p_id" lazy="false" not-null="true" />
</class>
</hibernate-mapping>
Name and version of the database you are using:
MySQL, version 4.1