I am new to database optimisations and I've been creating Rails apps for some time now, by using scaffolding tools, generators and web tutorials. So far, pretty much everything works fine, no big loads of users/traffic/data and the UX is flawless.
I have just started to create a huge application that will hold customer support tickets and updates, so I am starting to worry about performance in the near future. I only remember indexes from my university education as database references for fast search.
What is unclear to me is when should I use them and how? I've seen the scaffolders add an add_index
for the id and created_at datetime of a new model but I don't know If they are right to use and what should I add by myself in order to keep the object retrieval speed to an optimum/fast level and also learn common practises when creating models.
I've also seen indexes including 2 or more fields. Why?
My models are User
, Customer
, SupportTicket
, so any recommendations will be appreciated. I am looking into possible examples in Rails.