php - Insert query locking down the entire DB and not responding -


i have normalized (3nf) database ticket booking/purchase application, used throughout country traveling company. in mysql.

recently has exceeded 1gb (dump size) , queries has become sufficiently slower. in order reduce query time , db size (greatly), thinking doing cheating.

i'm going dump data offline server management can view history older 3 months. remove old data (by querying) online database. trust me older data isn't important in here.

the old data important how many time registered passenger has travelled company. though it's not greatest idea, i'm planning on adding integer value "passenger" table i'll keeping old count. simple that.

but here's problem. when run following query, phpmyadmin (or adminer) hangs up. server , somehow table gets locked. doesn't work unless restart server.

here's query. it's pretty

update `passenger`  set `countaddition` = (                        select count(1) booking                         booking.passenger = passenger.id                        ) 1 

i've given around 30 minutes run. never ends. might have gone wrong it? hugely appreciated.

also, if there better alternative one, please suggest.

subquery not work without group , why not showing progress.


Comments