Don't run a query if it can't return any results

Fixes #16506

Don't make a trip to the database if a query's WHERE clause ensures it would return zero results. For example:

```
Post.where(id: []).to_sql
'SELECT "posts".* FROM "posts" WHERE 1=0'
```