Browser issues with AJAX, PHP and MySQL

Browser issues with AJAX, PHP and MySQL

Author
Discussion

mystomachehurts

Original Poster:

11,669 posts

251 months

Friday 14th December 2007
quotequote all
A web page has a click function that submits a set of filters to the DB via a php page via AJAX.

The php page just performs a count of the records that match the filter criteria submitted in the AJAX request (grabbed fro ma form on the HTML page)

If this takes a long time to perform, is there a way to get the browser to stop the process that is running on the server performing the query?

I've got a few impatient customers that are complaining about the speed of this Application, what I'm seeing is that even if you click out of the web page that is waiting for the result it doesn't stop the MySQL MySQL process on the server from spinning out of control...

Boo Hisss


We're running CentOS:2.6.9-55.0.2.plus.c4smp #1 SMP Fri Jul 6 05:25:07 EDT 2007 i686 i686 i386 GNU/Linux
(and currently testing a 64bit 5 version of this OS)

MySQL is currently V5.0.44

Any thoughts?



cyberface

12,214 posts

258 months

Friday 14th December 2007
quotequote all
The middle tier will have to terminate the query (PHP?) - these sorts of apps aren't my forté so just guesswork about your middle tier. Usually a query object going out of scope ought to call the destructor and terminate the query but sounds like you need to do this manually.

A simple SELECT should stop when you terminate the query or the connection from the client to the server (from the app server to the DB server) is lost. However if your 'query' is some complex stored proc that returns a recordset but does a bunch of working-table inserts / updates / etc. then terminating this would make the DBMS roll back all the work done to produce the query... which means don't use 'real' tables as work table in select stored procs as they'll need to rollback the log if terminated half-way.

Also if you're running the app server on the database server (yuk) and the SELECT is a nasty unindexed affair (is this the same app you've been trying to get free PH consultancy on for months now mate? hehe ) then you may just be experiencing memory clearup - esp. if the SELECT does a big in-memory sort... killing it half way through will need to release all the memory grabbed by the middle tier to run the query.

Anyway it's Friday, my GF is not coming home till 3 am because of her office party and I'm off my head on lovely Thatcher's Katy cider, and I've had a bloody hectic week reverse engineering the worst spaghetti SQL you've ever seen, and this is a business consultancy role I've taken, not a techie one. Only way to get the answers is to do it myself, unfortunately.... frown

Are you going to be coming over in Jan mate? Give me a shout if you're staying with your mate and we'll meet for that beer - things are turning round for me now beer