In my app I want to aggregate some data in staging InnoDB table and then copy that data to Columnstore table using INSER INTO ... SELECT FROM query. After that I truncate staging table and aggreagate new rows for copy. The problem is that in some occasions it could be some rows that already had been copied to columnar table. In this case I want to merge data and update it in columnar table. There is no any keys or constraints in both tables and 'ON DUPLICATE KEY' statement is ignored by MariaDB. What are the best practicies in this case?
UPD: I have two identical tables
CREATE TABLE table_row (
id varchar(256) not null,
...
changed_at timestamp not nul
) ENGINE=InnoDB
CREATE TABLE table_column (
id varchar(256) not null,
...
changed_at timestamp not nul
) ENGINE=Columnstore
- Aggregating data to table_row
- INSERT INTO table_column SELECT * FROM table_row
- TRUNCATE table_row
- repeat
On the second step I need to handle duplicated ID's and update changed_at column instead of inserting all rows into table_column table.
As you said, you can't use
UNIQUEkeys with ColumnStore, soON DUPLICATE KEYcan't be used neither.Can't you keep an InnoDB table with the ID's of the rows that should already exist in ColumnStore? Then you could do something like this: