3 ms·
> I've worked in projects where no one seemed to know SQL, where massive speed improvements were made by fixing very low hanging fruits like removing select * q
by iamcreasy 4y ago
> I've worked in projects where no one seemed to know SQL, where massive speed improvements were made by fixing very low hanging fruits like removing select * queries, adding naive indexes, removing N+1 queries etc.
Can you recommend any SQL book with main focus on performance improvements like this?
- doodlesdev 4y agoJust know SQL, as noted these are really low hanging fruit. If you know SQL you should know about these.
- fredrikholm 4y agoI've learnt as I've needed it, so I'm afraid I don't have a single source to point at. Of the things that I've listed, a quick google search on each should give you enough info to be useful. > Select * queries Sometimes you only want two columns, but you ask for 5. Say you query a million rows, where you ask for but throw away 60% of all the data you get back. > Naive indexes As in, just slapping an index on a table that doesn't have one makes such a big difference that sometimes it's all you need. > N+1 queries This is more of a problem in ORMs, but any time you call the database N times instead of 1 time. A classic example is writing a for loop that asks for one row at a time, instead of asking for all rows once.
- bart_spoon 4y agohttps://use-the-index-luke.com/ https://use-the-index-luke.com/