Optimization of Firebird queries (online course)