From rough overview…
2.5s is generally fine for query performance. If you see it sometimes executing basically instantly and other times taking a long time it’s likely a deadlock situation. You can probably test this by making a form with a bunch of bindings that are populating datasets using the same query. Simulate multiple clients pounding it simultaneously. Don’t do that when the production system is using the database (I’m assuming this is only select queries).
The next step I would recommend is taking a copy of your script to a test page and calling it from a button using sample data. Isolate each part of the process to see where you’re getting into the chunky performance and figure out why they’re taking a lot of time.
If you can’t make things perform faster; spin up a thread to execute them so the processing isn’t locking up your main thread.