Ad
MYSQL Insert And Delete At The Same Time IMPACT
Here is the scenario.
I have a schedule job running every minute which inserts data into a MYSQL table "demo". The total number of records per day are 60*24 = 1440.
Table demo already has 55000 records.
I want to clean records less than today's date. Therefore I am using below code to do the work daily at 10.00 AM.
$demo = Demo::whereDate('created_at','<', Carbon::today());
if(count($demo) > 0)
{
$demo->delete();
}
Now a point will come where at the same time I am inserting to the same table and deleting from the same table.
I want to know that it will be safe? Or there will be an error or any other impact.
Ad
Answer
I don't think this will be an issue, since Carbon::today()
returns 00:00:00
as time and you are executing the deletion job at 10:00:00
. Only records that are inserted more than 10 hours ago will be deleted.
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad