Refactoring APEX to keep all database calls outside of for loops
The first step would be to create a set of Timelogs that you are interested in and then query for the related Worklogs. Querying Timelogs and getting child Worklogs is probably the simplest solution.

Sample code:

Set&lt;Id&gt; timelogIds = new Set&lt;Id&gt;();
for (Worklog__c worklog : worklogs) {
  timelogIds.add(worklog.Timelog__c);
}

// Get timelogs and related child worklogs
Map&lt;Id, Timelog__c&gt; timeLogs = new Map&lt;Id, Timelog__c&gt;(
                             [SELECT Id,
                             (SELECT ... FROM Worklogs__r) //query child relationship
                             FROM Timelog__c 
                             WHERE Id IN :timelogIds]);

for (Worklog__c worklog : worklogs) {
  List&lt;Worklog__c&gt; tempList = timeLogs.get(worklog.Timelog__c).Worklogs__r;
  // iterate through tempList to check for overlapping records
}