3 ms·
Do your queries SELECT, only to use subset of columns? Or do you extract many rows, only to use a subset? All the database optimization in the world won't hel
by gaius 16y ago
Do your queries SELECT, only to use subset of columns? Or do you extract many rows, only to use a subset?
All the database optimization in the world won't help you if your developers only know how to do
SELECT * FROM MYTABLE;
- morgo 16y agoIf they understand how to use memcached, but they can't do: SELECT col1, col2 FROM mytable; .. then something is seriously wrong with the world.
- spudlyo 16y agoSometimes it's not that big of a deal. The idea is if you specify only the columns you need, sometimes those columns can be satisfied directly from the index (what's known as a covering index) and you don't need to seek around to the various data pages to pull the rest of the columns. InnoDB though uses a clustered indexing scheme, where the rest of the columns are stored in the leaf nodes, so if you query by primary key, all the data is right there -- no extra seeking. Anyway, obviously it's better to only ask for what you need, but it's not the stupidest thing in the world to SELECT with wildcard.
- gaius 16y agoWell, also that you're not physically moving data you don't need across the connection. I have literally seen "programmers" simply select like that and filter out the rows they want, or sort the entire table (and then filter out the rows), in their own code. Madness.