From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | "hari(dot)prasath" <hari(dot)prasath(at)zohocorp(dot)com> |
Cc: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: full table delete query |
Date: | 2016-05-03 14:28:36 |
Message-ID: | CAKFQuwYwejd0sVjRiWx+gX2a8BM1Ro-7XDN5Otrrk021C2mPGA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, May 3, 2016 at 5:51 AM, hari.prasath <hari(dot)prasath(at)zohocorp(dot)com>
wrote:
> Hi all,
> How postgresql handles full table delete in terms of loading the
> full table in these scenarios
>
> consider one big table(tablename: bigtable)
> and the query will be >> delete from bigtable;
>
> 1)which doesn't have any foreign table reference with any other tables
>
> 2)And when this table is referenced by other table
>
>
You should at least consider whether you can use TRUNCATE, especially in #1
An actual delete has to modify every page for the table so it can mark
every row as having been deleted. I don't think it needs to load TOAST
data but am uncertain. I reasonably confident all non-TOASTED data will
end up in buffers.
References would depend on CASCADE behavior but in a restrict mode only FK
resolution triggers will be involved. In most well-design scenarios
indexes are then used instead of the corresponding triggers. So less data
but still likely every row will be read in.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Craig Ringer | 2016-05-03 14:35:04 | Re: Processes and caches in postgresql |
Previous Message | Craig Ringer | 2016-05-03 14:26:40 | Re: Logical decoding timeline following fails to handle records split across segments |