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
Support 'ON CONFLICT DO NOTHING' for compressed chunks #4113
Comments
@wiebeytec This is essentially the same problem as 3323. We cannot support this enhancement without support for 3323. |
Also really keen to see a fix for this. As with many (most?) systems, I can't guarantee there will be no duplicates, so without this enhancement (more of a bug fix TBH, since it was treated as such in #100 for non-compressed hypertables) I need to check if rows exist before inserting them, which absolutely decimates performance 😭 |
also as discussed here on slack. Would love to see this feature. |
Issue:Consider below example table: CREATE TABLE sample_table ( -- create hypertable -- populate hypertable -- show_chunks Above chunks are child tables of sample_table. These chunks inherit UNIQUE CONSTRAINT from sample_table. --enable compression Enabling compression creates a new compressed table _timescaledb_internal._compressed_hypertable_2 \d _timescaledb_internal._compressed_hypertable_2 Note that UNIQUE CONSTRAINT is not created for this new compressed table. -- compress the chunks -- INSERT duplicates: -- INSERT duplicates WITH ON CONFLICT If i comment the above error handling code, timescaledb ends up inserting duplicate rows. This is because there is no UNIQUE CONSTRAINT on the compressed table. Questions:
I will clarify above questions with my team and further proceed on how to approach this problem. |
Refer #5252 |
wow. cool. Super happy to be able to use this feature. |
#5252 has been merged. |
What type of enhancement is this?
User experience
What subsystems and features will be improved?
Compression
What does the enhancement do?
When there are compressed chunks and you do
INSERT ... ON CONFLICT DO NOTHING
, it says: "insert with ON CONFLICT or RETURNING clause is not supported on compressed chunks".Currently, if you have an ingress system that processes duplicate values while back-dating, you can't use compression, even if you just want to ignore the duplicates.
It's a light-weight version of #3323: only supporting
DO NOTHING
is fine when having unique keys. However, perhaps it's essentially the same problem, I don't know.Implementation challenges
I tried patching the code as per attached patch (Or github compare (for as long as the link works)). The problem with it is that despite there being a unique index, duplicate values are inserted. I don't know if fixing this (checking for the value in the compressed index) is essentially the same as #3323, or that
DO NOTHING
can more easily be implemented.timescaledb-compressed-do-nothing-fix.patch.txt
The text was updated successfully, but these errors were encountered: