It’s almost impossible to troubleshoot something like this in a vacuum… to give a good answer we would need to know the layout of the table(s) involved and the indexes for starters. But there are a couple of things to consider
Like @TomLiotta said stop using OPNQRYF. It’s old and it does not take advantage of the SQL Query Engine (SQE) on the system, there are just too many benefits to using the SQE to cover them here… check out these articles:
A good article by Kent Milligan:
Also gathering some statistics with STRDBMON will at least help identify potential indexes to be built.