You could use
readOnly="true" in your
See here for more information as there will be some limitations to doing this, for example:
While Visualforce pages that use read-only mode for the entire page can’t use data manipulation language (DML) operations, they can call getter, setter, and action methods which affect form and other user interface elements on the page, make additional read-only queries, and so on.
But this will relax the limit as it says:
Normally, queries for a single Visualforce page request may not retrieve more than 50,000 rows. In read-only mode, this limit is relaxed to allow querying up to 1 million rows.
Seeing as you editted your question to say:
I dont need to use this in a vf page.
I will be using this COUNT() SOQL Query in a batch class which is scheduled to run at specific time.
There is also a @readonly annotation you could take a look at which:
allows you to perform unrestricted queries against the Force.com database.
Again, with some limitations:
All other limits still apply. It's important to note that this annotation, while removing the limit of the number of returned rows for a request, blocks you from performing the following operations within the request: DML operations, calls to System.schedule, calls to methods annotated with @future, and sending emails.
Hopefully this might give you some ideas on how to meet your requirement.