Jump to content

Can ActiveRecords handle multi-column $databaseColumnId?


Go to solution Solved by KT Walrus,

Recommended Posts

Posted

I have an ActiveRecord table with a multi-column primary key. The ActiveRecord class has $databaseColumnId that appears to require a single Id key. My table doesn't need a single column key as it only adds another secondary index for the table (that wastes disk space, memory, and processor time).

Is my only option to set $databaseColumnId to an auto-incremented column and define a secondary index for this column? This is a waste (to have an extra secondary index) when the ActiveRecord has a multi-column primary key.

Seems to me the ActiveRecord class should support an array of column Ids for $databaseColumnId when the primary key is multi-column.

I require a multi-column primary key to keep all rows that have the same value for the first column in the primary key clustered closely in the clustered index. These ActiveRecords are list elements for lists (where the list_id is usually a member_id). When I select list elements for a given list_id, I want the row data to reside in adjacent pages of the clustered index (for maximum MySQL server performance). 

  • Solution
Posted (edited)

I decided to just add an extra 'id' column (auto-increment, unique index). This is unneeded except that the System Classes seem to all expect primary  keys and secondary unique indexes to be single-columns.

Edited by KT Walrus
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...