The limit should occur in the query itself, not afterwards. Use `$db->sql_query_limit($sql, 10)` instead of `$db->sql_query($sql)`.