title: Will a many-to-many table with billions of records cause performance issue?
body: <p>I'm building a database contains 3 tables.</p>
  
  <ol>
  <li>Users table, (ID, UserName)</li>
  <li>Products table, (ID, ProductName)</li>
  <li>Rating table, (ID, UserID, ProductID, Rating)</li>
  </ol>
  
  <p>I potential will have nearly 100m users and 5000 products. Although not every user rated every product, it's still reasonable to assume that my Rating table will have billions of records. My knowledge of database is limited to SQL queries, so I'm wondering will it become super slow when I wish to select all ratings made by one particular user.</p>
  
  <p>Thanks</p>
  
  <p>Update: Regarding to the Rating table, is it necessary or has any benefits to keep ID column, if I make <code>UserID</code> and <code>ProductID</code> as Primary Key? When it comes to modelling, I'm only using one user's ratings at a time, i.e. select all ratings belong to user1, do stuff on these records, select user2 ratings, do stuff on these records, so on and so forth. In terms of convenience and efficiency, any better database structure than many-to-many table?</p>
  
  <p>update2:</p>
  
  <pre><code>| time_spent | CREATE TABLE `time_spent` (
    `product_id` mediumint(9) NOT NULL,
    `user_id` bigint(20) unsigned NOT NULL,
    `minutes_spent` int(10) unsigned NOT NULL,
    PRIMARY KEY (`user_id`,`product_id`),
    KEY `index_product_id` (`product_id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci |
  </code></pre>
  
  <p>where product_id is 6 digits long, but might become longer in the future; user_id is 17 digits long.</p>