Thread: Need help on creating index for a query w/ 4 greater-than conditions

Need help on creating index for a query w/ 4 greater-than conditions

From
Fan Chi Kam
Date:
What sort of indexing I should use if I try to run the following query?

SELECT part_id  FROM part   WHERE dimen1 >= ? and dimen2 >= ? and dimen3 >= ? and dimen4 >= ?  ORDER BY dimen1, dimen2,
dimen3,dimen4  LIMIT 100;
 

I tried creating index on the dimen1, dimen2, dimen3, and dimen4 columns,
but this dosn't help at all.  The query plan I always get is sorting
followed by a seq scan.

Sort  (cost=2822.86 rows=622 width=96) ->  Seq Scan on part  (cost=2822.86 rows=622 width=96)

Thanks