https://planchecker.cfapps.io/plan/Edo2MMbv
EXPLAIN (ANALYZE, COSTS, VERBOSE, BUFFERS, FORMAT JSON)
SELECT COUNT(*) AS "__count"
FROM "juliet"
WHERE ("juliet"."whiskey" IN ('F') AND "juliet"."three" <= '2001-04-30')
there is an index for this field juliet.three, how can I make sure this query uses the index?
let's say the table has 10N rows and this query returns 3N rows so counting 30% of a big table.
whiskey is an enumeration field which is kept as a charfield without an index. Maybe this is the problem, I'm not sure if the problem is at the charfield or the date field.
the table size is in the order of millions.
Also I got a warning like this:
WARNING: Filter using function | Check if function can be avoided
how can I avoid functions? is it possible?
format textthen edit your question and add the execution plan generated with that option (as formatted text, no screen shots please).option jsonis for computers to read, not for humans.count()function - you can't avoid that in that query. An index on(three, whiskey)or(whiskey, three)might help - depending on which of the conditions is responsible for filtering out the majority of rows.(whiskey, three)?