Is the system column "ctid" legitimate for identifying rows to delete?
16
votes
2
answers
8427
views
I have a table with hundreds of millions of rows that I need to delete data from.
The existing indexes are the most efficient.
I can however use the existing indexes to find the rows to delete by using the
ctid
values:
DELETE FROM calendar_event WHERE ctid IN
(SELECT ctid FROM calendar_event WHERE user_id = 5 LIMIT 100 FOR UPDATE)
What are the risks of relying on the ctid
in this case? My worst case scenario is deleting the wrong the row.
Asked by ruelloehr
(261 rep)
Aug 8, 2018, 05:54 PM
Last activity: Oct 20, 2024, 11:31 PM
Last activity: Oct 20, 2024, 11:31 PM