How can I apply heuristics to optimise an expression tree? I've converted the following SQL query:

SELECT name
FROM dog d, works_at w
WHERE (d.owner_name = w.person_name) AND (w.kennal_name = "Breeders");


into the following expression tree:



My main question is how does one apply heuristics to optimise an expression tree?

And is it OK to use the abbreviaions (e.g. dog as d) in the query tree, or do I have to write out dog.owner_name in place of d.owner_name?
I've just figured out how to do this, so I'll answer it in case anyone else has a similar problem.


Introduced SELECTs as far down the tree as possible, to reduce the number of comparisons needed.
Introduced PROJECTs as far down the tree too, to reduce the number of columns.
Used a JOIN wherever a CARTESIAN PRODUCT was followed by a SELECT. (There weren't any in my tree but this is what's done apparently).


My final tree looks like this: