Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Application slow on the first run, then speed is ok
I have a GUI Qt application that works ok. When clicking on one button, I launch a very heavy function (in terms of consuming) as there are multiple sql query, excel opening/closing and file writing in each iteration of a single loop.
When I start the app for the first time of the day and click the button, it takes about 20 mins to run. Then if I re-run it, it takes less than 2 mins (even if I re-run it 50 times). I mention that the function does exactly the same thing every time it is launched (there is nothing like "if this is has already been done today, then just update...")
Could you please help me with this issue? Basically I will be very happy if I can run it in two mins when I launch it for the first time of the day.
Thanks for taking the time to read.
koahnig last edited by
Hi and welcome to devnet
This sounds like a buffering issue, but is not related to Qt.
When you say first time of the day, you mean after booting your system I guess. Another test you can do is shutting down your system and booting again. Probably it will take another 20 min and be faster afterwards.
Waiting 20 minutes or even "only" 2 minutes is really long. You may want to think about ways to bridge those wating times. One possibility may be loading in a separate thread or possibly loading spread over different thread when on a multi core machine.
mcosta last edited by mcosta
if your DB runs on the same machine probably it uses cache to optimize some queries; so could be the reason of this behaviour
Hi koahnig & mcosta,
I have not tested to shut down and the run it again, I'll try it, but you are certainly right. 2 mins may sounds very long indeed, but there are billions of calculations, and basically I am happy to be able to run it in 2 mins (The first time I wrote the code for this purpose, it was in VBA and used to take 25/30 mins (everytime ;) ).
Your idea seems very likely to be a good explanation, I have not think about it. Indeed the DB is a local one.
Is there a way to load the cache before? (maybe opening and closing an ODBC connection prior to run my function?)
Thanks for your help
mcosta last edited by
Is there a way to load the cache before?
I don't know. But you should refer to the DB documentation
Ok thanks, I'll look at it.