Depending on the DBMS, I don't think in most cases that you CAN interrupt a query once it has been submitted to the DBMS. You may very well be able to close the connection, but (having worked with MANY DBMS's) it is up to the DBMS designers as to whether the (D😎 server recognizes this and stops execution of the query.
Remember that there are two servers involved; the DB Server (mySQL, PostgreSQL, Oracle, DB2), and the web/application server (IIS, Apache, Tomcat, Websphere). You may be able to pseudo-thread your application, but once it submits a query to the DB, that particular thread will block until the DB returns an error. Even if your application closes, the DB <u>may</u> continue to process the query to fruition, depending on how well it is designed!
Having said all that, if your query is taking too long to return a few result rows, then you need to:
a) Optimize your query
b) Optimize/change your database schema
c) Install a better DBMS
d) Get more horsepower (better hardware)
e) All of the above
If the problem is that your query returns too many rows, then you can usually use <b>LIMIT</b> and <b>OFFSET</b> to loop, retrieving and displaying a few rows at a time.
If you don't want the user to have to press <b>Next/Previous</b> buttons, then have the search happening in one frame in a loop using the above method. Each time through the loop, spit out the records and then check a session var to see if the user wants more or clicked a STOP button. In another frame, put a simple form with just a stop button. When the user presses that, run a script that just sets the session var that the search script checks in the loop.
To the user, the search script never stops, but the user has the option to stop searching / listing results at any time.
HTH
-- Rich