Preprocessing methods called “readorning” and “bottom-up adorning” are introduced as means of enlarging the application domain of magic sets and related query optimization strategies for logic databases. Readorning tries to make possible the simultaneous use of multiple sideways information passing (sip) strategies defined for a rule, thus yielding an optimization effect that may not be achieved by any particular choice of sip strategies. Bottom-up adorning is used to make magic sets applicable to cases in which potential optimizations can be derived from bindings coming upwards from rule bodies to rule heads in bottom-up evaluation. These include the cases in which we know that some base relation is small or that the domain of an attribute of some relation is small. Bottom-up adorning followed by readorning will propagate these bindings to other parts of the datalog program.