CoolCMS API

BatchDelete
in package

FinalYes

Retention `DELETE` in batches (`LIMIT`) instead of one unbounded statement.

A single DELETE over hundreds of thousands of rows holds row locks and the undo log for its whole duration and blocks writes to auth tables (login, rate limit). Batches release the locks progressively. The loop ends when a batch deletes fewer than $batch rows or the time budget runs out (the next cron run deletes the rest).

Table of Contents

Constants

DEFAULT_BATCH  : int = 5000
DEFAULT_TIME_BUDGET  : int = 25

Methods

run()  : int

Constants

DEFAULT_TIME_BUDGET

public int DEFAULT_TIME_BUDGET = 25

Methods

run()

public static run(Connection $connection, string $sql[, array<string, mixed> $params = [] ][, int $batch = self::DEFAULT_BATCH ][, int $timeBudget = self::DEFAULT_TIME_BUDGET ]) : int
Parameters
$connection : Connection
$sql : string

DELETE FROM ... WHERE ... without LIMIT (it is appended here)

$params : array<string, mixed> = []

named query parameters

$batch : int = self::DEFAULT_BATCH
$timeBudget : int = self::DEFAULT_TIME_BUDGET
Return values
int —

total deleted rows

On this page

Search results