In a migration, a partial index is defined as follows to have only column price_1 where its value is greater than zero.
add_index :products, :price_1, where: "(price_1 > '0')"
the schema states
add_index "products", ["price_1"], :name => "index_products_on_price_1"
and the migration states
-- add_index(:products, :price_1, {:where=>"(price_1 > '0')"})
Neither rails nor postgreSQL seem to have complained.
However I am unsure as to whether the syntax is correct across the stack... and given this index is mission critical, I'm asking 'is air tight'?
exclude NULL values is also required. But I believe the definition covers that.
"(price_1 > '0')"
be"(price_1 > 0)"
? You are comparing numbers rather than strings, aren't you? – Uri Agassi Jun 18 at 10:40price_1
is a number... have you run any tests to see if it works as expected? – Uri Agassi Jun 18 at 10:46