Is dere any way i can rewrite the query so that i need not to set seqscan-off, because i dont want to embed one more line in application code and also dont want to change global setting in postgresql.conf to disable seqscan.
You can use a specific user for this query and set parameter's value at user level.
But if you don't have any way of doing that then you pretty much have to "embed one more line in application code" [though I have never understood why application teams do not want to do that]. It should be fine, unless you are developing a product which can be used with someother RDBMS and hence you don't want to introduce a PostgreSQL specific line in code.
Best Regards,
Sameer Kumar | Database Consultant
ASHNIK PTE. LTD.
101 Cecil Street, #11-11 Tong Eng Building, Singapore 069533