MySQL Triggers

If you have a table of GPS data ,that keeps getting written to, and starts to run to millions of records. It is a sensible idea to create a trigger under mysql to update a scratchpad summary table on an insert to the table.You can additionally run a simple cron job to clean out the data every  night such that it keeps the last 7 days worth of data, that way you  can amend your queries to work against the scratchpad for realtime info for clients, and ensure responsiveness is kept high.

 

If you are looking for only the last record in each instance, then  you could simply not bother with cron, but create the trigger using replace and a suitable primary index, and it would manage itself always having the last record available to you.

 

 

 

×

Comments are closed.