parsed.org

Tips by tag: expressions

Booleans In The WHERE Clause by xinu on May 03, 2005 05:21 PM

If you're going to use a boolean condition in your where clause, you're going to want to make sure you use an operator so that the index is used (if present).

For example, this will not use the index:

db=> SELECT id FROM users WHERE active;

This will use the index:

db=> SELECT id FROM users WHERE active = true;
expressionsgotchaindexperformancepostgresqlsql
RSS