KT Walrus Posted February 20, 2022 Posted February 20, 2022 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 KT Walrus Posted February 21, 2022 Author Solution Posted February 21, 2022 (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 February 21, 2022 by KT Walrus
Recommended Posts