1 Reply Latest reply on Sep 9, 2013 2:32 AM by Kutir Mobility

    Rhom indexing "object"

    Jon Tara

      When using fixed schemas, does Rhom automatically add an index for "object" (the built-in unique ID property), or would I have to add that myself? If the latter, I would do it like this?


      unique_index :by_object, [:object]


      Are indices used automatically? I see I have to assign a name to each index. Where/when/why would I use these names?


      There's scant documentation on fixed schema indices. Any illumination would be helpful.

        • Re: Rhom indexing "object"
          Kutir Mobility

          "object" is declared as the primary key of the table and sqlite creates an index automatically for its primary keys. From the sqlite docs at http://www.sqlite.org/lang_createtable.html :


          INTEGER PRIMARY KEY columns aside, both UNIQUE and PRIMARY KEY constraints are implemented by creating an index in the database (in the same way as a "CREATE UNIQUE INDEX" statement would). Such an index is used like any other index in the database to optimize queries. As a result, there often no advantage (but significant overhead) in creating an index on a set of columns that are already collectively subject to a UNIQUE or PRIMARY KEY constraint.


          Therefore, you need not worry about creating an index manually for "object", it will be managed and used automatically.


          Hope that helps,


          Kutir Mobility