0

I'm contemplating the following schema:

create table pool
(
    id integer not null
        constraint pool_pk
            primary key,
    contact_index integer not null,
    contact_id integer[]
);

Basically a large array of integers, which could be as many as 1 million - and are only written once, and an index value into them that is updated over time.

My question is:

If I update the contact_index field will that cause a rewrite of the entire row, or is the large array field stored "off page" somehow?

1
  • 2
    "If I update the contact_index field will that cause a rewrite of the entire row," yes, it will. You are better off with a properly normalized model using a one-to-many relationship Commented Aug 25, 2020 at 7:31

1 Answer 1

1

An array of 1e6 integers will be stored off page in TOAST. If you update something else in the row, the TOAST data does not get copied for the new row version, just the TOAST pointer does.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.