Hi Kunal,
we need more information to help you here. How does your query look like? Does it benefit from index structures (please check out the output in the QueryInfo panel)? Are your index structures up-to-date?
while I fired query to retrieve all the records it will take approx 30 secs to execute a query.
System.out.println(result.size());
Just in case: printing something to stdout takes often much more time than evaluating the query.
Christian