I am deploying a Rails application that combines coupon data from various third-party providers into a searchable database. Searches are carried out in four fields for each coupon: title, coupon code, description and expiration date.
Since some of these third-party providers do a pretty poor job of sorting their data, and also because I don't want duplicate coupons populating my database, I implemented a unique composite index in these four columns. This prevents inserting the same coupon into my database more than once.
Given what I'm looking for against these columns (through a simple comparison WHERE column LIKE %whatever%so far), I want these columns to be separately winnings from the speed that would need to be indexed.
So, my question is: will the combined index across all columns provide the same increase in search speed, as if I applied a separate index to each column? Or does it only guarantee uniqueness between the lines?
The complication of the question is that I am developing in Rails, so my question is about both SQLite3 and MySQL (and whatever we carry over in the future), and not just one specific RDBMS.
I suppose indexes will speed up searches on individual columns, but I really lack the knowledge of the database “under the hood” to feel confident in this proposition.
Thank you for giving us your knowledge.