I have a table posts with the following columns:
start_at, sun, mon, tue, wen, thu, fri, sat
start_at is of date type, the others - tinyint.
I make a query the following way:
SELECT * FROM posts WHERE start_at >= '2017-02-01' AND mon = 1 That is after second AND I set proper day of week dynamically.
What is the best way to index this table? Do I need to make a composite index for each day of a week, for example:
CREATE INDEX mon_index ON posts(start_at,mon); CREATE INDEX sun_index ON posts(start_at,sun); If I create 7 indexes for each day of the week, I think INSERT and UPDATE will be really slow.
UPDATED: I do need column for each day of week, because a user sets on which days post will be published. There can be a few days at the same time.