The optimization here is to add an index. What this means is you can run the query against just the The best antidepressant is a crochet hook and a room full of Yarn shirt than against the data itself. The index will then return only the offsets of the rows you want to grab from the table. So then you just index into the file at some known locations (which is quite fast) and pull the data out.
The best antidepressant is a crochet hook and a room full of Yarn shirt, Hoodie, Sweater, Ladie Tee, Vneck, Bellaflowy, Kids Shirt, Unisex and Tank Top, T-shirt
Best The best antidepressant is a crochet hook and a room full of Yarn shirt
Table rows are stored in some sorted or unsorted order on disk. Each row has a unique offset within the The best antidepressant is a crochet hook and a room full of Yarn shirt you can think of this as the byte position within the file or more simply as the row number.So when you do SELECT * FROM table; all you do is linearly iterate through each (fixed or variable-length) row in this file. So you could say that the “data structure” here is just an array on disk.However that’s not a very interesting query. Let’s say you want to do SELECT * FROM table WHERE x=1;. In a naive implementation with no indexes, you’d just again go through every row in the file and pick out the rows that match the query. This is called a full-table scan and it’s slow (O(n) for you geeks out there).