From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | Marcelo Fernandes <marcefern7(at)gmail(dot)com> |
Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Best Approach for Swapping a Table with its Copy |
Date: | 2025-02-12 21:40:25 |
Message-ID: | 9fa75099-1ee9-43de-ac6e-945841b184eb@aklaver.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 2/12/25 1:27 PM, Marcelo Fernandes wrote:
> On Thu, Feb 13, 2025 at 10:02 AM Adrian Klaver
> This is a simplified version of the original table:
>
> CREATE TABLE bookings (
> id SERIAL PRIMARY KEY,
> resource_id INT NOT NULL,
> start_date DATE NOT NULL,
> end_date DATE NOT NULL
> );
>
>> 3) The exclusion constraint definition.
>
> The copy table would have an exclusion constraint such as:
>
> ALTER TABLE bookings
> ADD CONSTRAINT no_date_overlap_for_resource_id
> EXCLUDE USING gist (
> resource_id WITH =,
> daterange(start_date, end_date, '[]') WITH &&
> );
Do you know this will not fail on the existing data?
>
>> 4) Definition of what 'fairly large' is.
>
> This table is over 400GB
Do you have room for a complete copy of the table?
>
> This is done to avoid having to hold an exclusive lock for a long amount of
> time, thus creating application outages.
I am not seeing how this can be done without some outage for that table.
What sort of time frame is acceptable?
>
> Hope that clarifies the situation a bit better
> - Marcelo
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Marcelo Fernandes | 2025-02-12 22:04:57 | Re: Best Approach for Swapping a Table with its Copy |
Previous Message | Marcelo Fernandes | 2025-02-12 21:27:55 | Re: Best Approach for Swapping a Table with its Copy |