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
Use the form ::type to ensure that a value is cast to the proper type:
SELECT * FROM table WHERE column = 5::bigint;
In this case, column is indexed and is a bigint. The index will not be used if the query planner doesn't encounter a value of the index type. Note: this only applies in PostgreSQL 7.x.
gotchaindexperformancepostgresqlsqlsyntaxtypes