Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unique constraint on squeeze table #69

Open
shruthikc-gowda opened this issue Mar 13, 2024 · 6 comments
Open

Unique constraint on squeeze table #69

shruthikc-gowda opened this issue Mar 13, 2024 · 6 comments
Assignees
Labels

Comments

@shruthikc-gowda
Copy link

shruthikc-gowda commented Mar 13, 2024

Hi,
This query is regarding the README information that says make sure that your table has either primary key or unique constraint.

postgres=# create table test ( id int, age int  NOT NULL );
CREATE TABLE
postgres=# alter table test add constraint unique_const UNIQUE (id);
ALTER TABLE
postgres=# insert into test values (generate_series(1, 5000), 30);
INSERT 0 5000
postgres=# SELECT squeeze.squeeze_table('public', 'test');
ERROR:  Table "public"."test" has no identity index

The code expects the table to either have a replica identity index or a primary key and does not check for the unique constraint. I am a little confused about the "primary key or unique constraint" mention in the README.

@kovmir kovmir changed the title Query regarding the unique constraint on squeeze table Unique constraint on squeeze table Mar 14, 2024
@kovmir
Copy link
Collaborator

kovmir commented Mar 14, 2024

Why a table to be squeezed requires a primary key or unique constraint, is that your question?

@shruthikc-gowda
Copy link
Author

My question is can pg_squeeze work when the table has a unique constraint and no primary key ?

@shruthikc-gowda
Copy link
Author

shruthikc-gowda commented Mar 21, 2024

Hi,
As per my understanding, pg_squeeze expects the table to have a primary key or a replica identity configured. I was wondering if the below line in the README needs an update ?

**Register table for regular processing**
First, make sure that your table has either primary key or unique constraint.

First, make sure that your table has either primary key or replica identity.

Also, one more observation is the README has the description for skip_analyze but is not part of any function definitions.

@ahouska
Copy link
Contributor

ahouska commented Mar 22, 2024

The problem is that the id column is nullable. You fix your test this way:

ALTER TABLE test ALTER COLUMN id SET NOT NULL;
ALTER TABLE test REPLICA IDENTITY USING INDEX "unique_const";

I'll adjust the documentation. Thanks.

@ahouska
Copy link
Contributor

ahouska commented Mar 22, 2024

skip_analyze is a column of the squeeze.tables table, not a function argument.

@shruthikc-gowda
Copy link
Author

Ok. Thanks for the response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants