Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Nov. 9, 2005 05:15:06

[EMAIL P.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Multiple field indexes


I have included in my models db_index=True for a number of tables and
my indexes do not seem to appear in my SQL. I have been using dump
facilies to verify what Django creates and I am not see create index
statements.

How do I a single index in a model for multiple fields. I have some
tables that use two fields together in an index so need a way of
expressing this. I have not found anything in docs at this point other
than single index.

Regards,
David

Offline

#2 Nov. 9, 2005 05:22:27

Kenneth G.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Multiple field indexes


On Wednesday 09 Nov 2005 10:44 am, wrote:
> I have included in my models db_index=True for a number of tables and
> my indexes do not seem to appear in my SQL. I have been using dump
> facilies to verify what Django creates and I am not see create index
> statements.
>
> How do I a single index in a model for multiple fields. I have some
> tables that use two fields together in an index so need a way of
> expressing this. I have not found anything in docs at this point
> other than single index.

unique_together
--
regards
kghttp://www.livejournal.com/users/lawgontally ho!http://avsap.org.inಇಂಡ್ಲಿನಕ್ಸ வாழ்க!

Offline

#3 Nov. 9, 2005 14:39:37

[EMAIL P.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Multiple field indexes


Hi Ken. Nice to hear from you. We seem to be on similar lists.

I am able to generate the create indexes statements for regular indexes
(django-admin.py sqlindexes myapp). They just don't appear in the
install (django-admin.py install myapp). Get everything but the
indexes. I am using sqlite3 with this.

An example model:

class Triple(meta.Model):
"""
"""
subject = meta.IntegerField(db_index=True)
predicate = meta.IntegerField(db_index=True)
object = meta.IntegerField()
objtype = meta.IntegerField()

class META:
db_table = "triples"
unique_together = (('subject',
'predicate'),('object','objtype'),
('subject', 'object', 'objtype'),('predicate', 'object',
'objtype'),)

I dont get index create statements on install for any tables. Unique
together gives me this:

CREATE TABLE triples (
id integer NOT NULL PRIMARY KEY,
subject integer NOT NULL,
predicate integer NOT NULL,
object integer NOT NULL,
objtype integer NOT NULL,
UNIQUE (subject, predicate),
UNIQUE (object, objtype),
UNIQUE (subject, object, objtype),
UNIQUE (predicate, object, objtype)

This is not indexes - but this is putting constraint on the data
instead.

Maybe I should file a bug report and I should do this after in a
regular statements after install :(

Offline

Board footer

Moderator control

Enjoy the 18th of November
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support