(features->>'capacity')::int < 300
, then the request still works very long (around 300-500 MS.). EXPLAIN (ANALYSE, BUFFERS) SELECT id, name, price FROM product features
WHERE (features->>'color')::int > 1000000
ORDER BY price ASC
LIMIT 25
Limit (cost=0.43..10.56 rows=25 width=161) (actual time=0.018..0.093 rows=25 loops=1)
Buffers: shared hit=51
-> Index Scan Backward using product_price_index on product (cost=0.43..317546.33 rows=783959 width=161) (actual time=0.016..0.071 rows=25 loops=1)
Filter: (((features ->> 'color'::text))::integer > 1000000)
Rows Removed by Filter: 23
Buffers: shared hit=51
Planning time: 0.068 ms
Execution time: 0.120 ms
create index on tablename using btree(((features ->> 'capacity'::text)::integer));
I.e. the index is used, although in this case the index is triggered on price column? Then why the request fulfills quickly?
Find more questions by tags PostgreSQL
it turns out that each numeric feature is necessary to index hands? :( is not very convenient. wanted to take as an alternative to EAV, try on a project and this is now forced to seriously think about. - Easter.Waelchi commented on June 10th 19 at 16:06
For catalog filters like silver bullet has not yet - Ignacio_Romaguera commented on June 10th 19 at 16:09