0

I am running a web application which has to scan (MySQL query on a particular column) a huge MySQL table, which has over 100,000 records.

The problem is that when a user requests another page from the same web application while the results are being fetched from the scan, the browser takes a long time to display the page.

How can I cancel the scan (or the MySQL query) while the new page is being requested?

3
  • 2
    Do you have indexes set up on that column to speed up searching? Commented Jul 7, 2014 at 6:57
  • Consider implementing indexes (as suggested by @Grandmaster). Another approach is to cache previously executed queries so all following requests for the same data are returned from cache. Also, consider implementing pagination and not return all 100,000s records. Canceling a query is too much hassle, and will upset your web users.
    – Roman Mik
    Commented Jul 7, 2014 at 13:12
  • Yes, I have indexes set up on that column. Actually I had to make a calculation in that large table by recursively calling it row by row using php script. This is actually slowing the things down.. I have decided to use the stored procedure(though I am new to it) in mysql.. Hope it speed-ens the things up.
    – Arun deep
    Commented Jul 10, 2014 at 18:24

1 Answer 1

1

You can't.... easily. Think about this from the user's point of view - why should their query be terminated because someone else is making another request? Fix your query to run faster so the system doesn't grind to a halt when somebody does something unexpected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.