(no title)
BeefWellington | 1 year ago
The key thing here is to understand that you want the minimal correct query for what you need, not to avoid "making the database work".
The given example is silly because there's additional parameters that must be either NULL or have a value before the query is sent to the DB. You shouldn't send queries like:
SELECT \* FROM users
WHERE id = 1234
AND (NULL IS NULL OR username = NULL)
AND (NULL IS NULL OR age > NULL)
AND (NULL IS NULL OR age < NULL)
But you should absolutely send: SELECT \* FROM users
WHERE id = 1234
AND age > 18
AND age < 35
deredede|1 year ago
What you shouldn't send is queries like:
because now the database (probably) doesn't know the value of the parameters during planning and needs to consider all possibilities.oever|1 year ago
tsarchitect|1 year ago