2021-03-11, 09:17 AM (ISO 8601)
Re: SQL: RIGHT or LEFT JOIN more efficient
I recognize that your OP question was theory rather than application, but as general advise, I always remind my programmers to do each step in isolation if you can help it. Sorts in one step, minimize each table about to be joined to the smallest size you can manage (making a sub-table with reduced variables for one; reducing down by filter criteria; and doing distincts), then doing joins. I can't count the number of times a programmer with 25+ years of experience who can run circles around me (a managers with hopefully competent but by no means exhaustive programming experience) has said that there's 'nothing wrong' with their code and it couldn't possibly be the issue and then I find that the code is trying to join 2-3 multi-million rowed, 300-variable dimension tables while doing a distinct and a filter and multiple complex case-whens.
Originally Posted by JeenLeen