Jump to content

Recommended Posts

Hello,

 

I basically have a cron job that runs once everyday at 12 midnight to find records that are 7 days or older and deletes them. I determine the age of record using php as when the user account is requested to be deleted i insert a timestamp into the database and set the account status to delete and then in seven days time it will get deleted.

 

Now as deleting these records are not a high priority as i don't really want them to be i have seen the term LOW PRIORITY. Thing is i have searched all over the internet and cannot find anywhere on how it works exactly and what effects it has etc.

 

Could anyone tell me how low priority works exactly and can it work with a DELETE statement?

 

Thank you,

PHPLOVER

 

 

Link to comment
https://forums.phpfreaks.com/topic/228504-mysql-delete-low-priority/
Share on other sites

Hi,

 

I was meant to say it's a MyISAM DB.

 

Thanks for the doc but the problem is it only says this about LOW PRIORITY:

If you specify LOW_PRIORITY, the server delays execution of the DELETE until no other clients are reading from the table. This affects only storage engines that use only table-level locking (such as MyISAM, MEMORY, and MERGE).

 

Now what i would like to know is; when the cron job is run and someone was updating there profile for example and/or registering on the website would MySQL say in err human terms (excuse the expression): ?

 

oh hello delete query i see your low priority, i have a select/insert/update query that needs processing, i see your low priority so i will first do my select/insert/update queries and when i got time and nobody else is doing any other queries i will come back to you and delete what you want me to delete, but for now i am storing you away until i have some free time to spare.

 

I am sorry for the expression but i guess it's easier to explain and understand that way.

 

My next question is, what about if MySQL starts deleting records and someone comes along and updates profile or registers on site for example, does MySQL pause the low priority delete query to give for example the INSERT/UPDATE query priority?

 

 

Thanks

PHPFAN10

ok, so you want to know if, while a low priority query is being run, it can be interupted by another query being initiated at a normal priority?

In my limited knowledge, I am fairly sure that once a query has been started it can't be stoped under normal running conditions untill it has completed.

I think this will be a problem however because:

A) your delete query is likely to run quick enough that it won't even overlap with any other activity

B) even if it did overlap, MySQL can run much more than 1 querie at a time.

 

So it's not really much of an issue as I see it.  I think you are totaly missing the mark with what low_priority actualy does.

In my limited knowledge, I am fairly sure that once a query has been started it can't be stoped under normal running conditions untill it has completed.

 

MySQL operations can be stopped, but that's at a DBA-level.

 

I think this will be a problem however because:

A) your delete query is likely to run quick enough that it won't even overlap with any other activity

B) even if it did overlap, MySQL can run much more than 1 querie at a time.

 

The time the query would take is completely relative to the size of the table, current server usage, server capabilities, etc. MySQL does support simultaneous queries, but table-level locking on MyISAM tables prevents the same table being written to by 2 queries at the same time.

 

Using LOW PRIORITY will do exactly what it says, delay execution until the table isn't being read/written from. If your table is frequently being accessed, then that's not a good idea as the query could be waiting infinitely. Once the DELETE has started though, it won't get interrupted by another query as it has table-lock.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.