There appears to be a fairly significant difference after setting up transaction log shipping (in Standby/ Read-Only mode) through the SSMS wizard, which generates jobs that then call on outside .exe to handle the backup and restore vs doing the log shipping through a hand-written script:
BACKUP LOG [DBName] TO DISK = 'Z:\DBName_TimeStamp.trn' WITH NAME = N'DBName_Log', INIT, FORMAT;
EXEC [LSServer].[master].sys.sp_executesql N'RESTORE LOG [DBName] FROM DISK = N''B:\DBName_TimeStamp.trn'' WITH STANDBY = N''B:\DBName.standby'';';
When utilizing the log shipping through the wizard the database seems to be ready immediately and does not experience any lag time the first time any stored procedure is executed/ query run. However, when I set up the backup and restore through my script above the first time a stored procedure is executed against the recently restored database it takes 10x or more time to complete (I originally asked about this issue here: After Restoring Log Shipping to Secondary Server, First Stored Procedure Execution is Slow ).
I've eliminated all possibilities of different disks/ hardware etc. causing the problem as the issue is now affecting the same instance/ database that was originally using the log shipping set up by the wizard and has begun to experience the same slow initial execution/ query after restore.
The .trn file sizes look the same which ever method I use.
What can be done to identify/ eliminate this difference without going through the SSMS wizard?
Some additional information included in the linked question:
The only difference being the primary server executes with 1.4 seconds of Wait time on server replies and the secondary takes 81.3 seconds.
I do see a large number of PAGEIOLATCH_SH locks from the first execution, as you predicted:
diff after first exec vs diff after second exec waiting_tasks_count 10903 918 wait_time_ms 411129 12768