开发者

Is searching for a specific table faster than searching for a particular entry in a particular table?

开发者 https://www.devze.com 2023-03-12 07:16 出处:网络
I need to create a history table for particular resource and am trying to decide how to design it. My current thought was to create a separate table for each instance of the resource and enter a new v

I need to create a history table for particular resource and am trying to decide how to design it. My current thought was to create a separate table for each instance of the resource and enter a new value whenever there is something to new add. Would that be quicker? Or s开发者_Python百科hould I try to put everything in one table and search through it? I am not too sure how to fit it in one table yet but I figured knowing if there would be a speed hit would be a good start.


It seems like you are looking for acts_as_audited.


If the data logically belongs in one table, put it in one table. Don't prematurely vertically or horizontally partition your data unless you have a good reason.


If you have a history, it would be simple enough to have a table like...

history_id | resource_id | history_event
1          | 1           | created
2          | 1           | updated with silly info

With an index on resource_id it will be plenty fast. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消