Table Name Aliases
Let’s show an alternate way to do the same queries above with table aliases:
mysql> select n.lastName, a.zip from names n left join addresses a on n.id = a.nameId;
is the same as:
mysql> select names.lastName, addresses.zip from names left join addresses on names.id = addresses.nameId;
We basically specified n to be an alias of names and a to be an alias of addresses. That way we don’t have to type the full table name. This is advantageous because each query is sent to the server via the network and the shorter we can make it, the faster things will happen.
Query optimization is a whole field of databases. Some people actually specialize in it. You can find a ton of blogs on speeding up queries.