Hi Deepak,
If the Detail__c part of this query exceeds your 100,000 rows, you will receive an exception, before you even try to receive the Master__c records. I’m not sure exactly what you’re going for, but here are a couple of approaches:
Query on the Master object with a subquery on the related Details within the execute() method. You might run with a limit on the batch size if that is a safe way to limit how many Detail rows you’ll receive. I have run this kind of process with as few as 1 records per batch.
Query on the Detail object but sort by Master Id, so you can finish and update objects as you go along. Implementing Database.stateful will allow you to keep a running tally of any incomplete objects between execute runs. This will eliminate the requirement that one Master object fit within the governor restrictions of one execute() mathod.
Thanks