PDA

View Full Version : Best way to abort long SQL query?



wdezell
11th September 2009, 15:55
What is the best method for aborting an overly-long SQL query?

I've got a Qt4.3.3 app that queries a MySQL database via QSqlQuery::exec() & steps through the QSqlQuery::value() results while QSqlQuery::next() is true. I plan to display a "Be patient" dialog to the user via a QTimer if QSqlQuery::next() hasn't begun returning within a certain time but I'd also like to provide the user with a "Query Abort" if needed.

For my Qt app I am guessing it's as simple as ignoring the returned result set (breaking out of the QsqlQuery::next() loop), right? Any consequences to this (like "unconsumed data" polluting result sets of future queries?

Also, I know mysqladmin can abort a query and command the db engine to cease expending resources executing it but I don't see access to this capability through Qt. Any suggestions?


Very sorry if these are overly-naive questions but this is an area in which I've had little experience.

Thanks for the guidance,
Bill

wysota
11th September 2009, 22:05
Also, I know mysqladmin can abort a query and command the db engine to cease expending resources executing it

As far as I understand it it needs a separate db connection to do that.