summaryrefslogtreecommitdiff
path: root/src/sql/accessLogPurgeOld.sql
blob: 18ec7750db894288a008593867d156b7fd94a4f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
WITH scope AS (
	SELECT
		id
	FROM
		access_log
	ORDER BY
		id
	LIMIT ?
),
scoperange AS (
	SELECT
		min(id) minid,
		max(id) maxid
	FROM
		scope)
DELETE FROM access_log USING scoperange
WHERE request_time < CURRENT_DATE - ?::interval
	AND access_log.id BETWEEN scoperange.minid AND scoperange.maxid