My DB table has one primary key and a number of integer columns and one boolean column called paused which is not in the primary key. This table will only ever hold a few hundred rows but I need to query the boolean column very regularly. I need to know if any row in the boolean paused column is true, if one row is true I will return true if all are false I will return false.
Should I create an index on the boolean column and what would that syntax look like or is there any other way to optimize that query?
CREATE TABLE IF NOT EXISTS pause_metrics (
consumer TEXT NOT NULL,
timstamp TIMESTAMP NOT NULL,
idle_counter INTEGER NOT NULL,
paused BOOLEAN DEFAULT FALSE NOT NULL,
PRIMARY KEY(consumer)
);
create tablestatements for the tables in question (including the existing indexes) and, the query you are trying to optimize. formatted text please, no screen shotspaused = false), then a filtered index might make sense e.g.create index on the_table (some_column) where not paused