I have table that has 5 boolean columns.
on_stock | paid | received_payment | on_the_way | received
How to create an index for this table? Should I do it? I want to optimize a query like this:
SELECT "order".* FROM "order" INNER JOIN "seller_users" ON "order"."seller_foreign_id" = "seller_users"."google_id"
WHERE(((("order"."on_stock" <> true AND "order"."on_the_way" <> true ) AND "order"."paid" <> true ) AND "order"."received_payment" <> true ) AND "order"."received" <> true ) AND ("seller_users"."google_id" = 'lala@gmail.com' )
ORDER BY "order"."updated_at" DESC ;
When I try add this index - nothing happens. This index is not used.
add_index :order, [:on_stock, :on_the_way, :paid, :received_payment, :received], :name => "state_index"
If I add separate index
for each columns - nothing happens too.
EXPLAIN ANALYZE
output:
http://explain.depesz.com/s/FS2