Hello everyone,
I have two tables in the same database and same schema. I am writing a program that uses this database in c/c++ using the libpq library. What I need to do now is move SOME data from the first table to the second. By move, I mean that I want the data inserted into the second table and removed from the first (as opposed to just copying it).
My questions are:
1) Is there a faster, better way of doing it other than:
a) insert into table2 select * from table1 where ...
b) delete from table1 where ...
? And if so, how would you do it?
2) Would it be faster to do data moving by executing each command from the c++ code, or would it be faster to create a postgresql procedure or function to do it, and then call it from the c++ code? If it's faster to create a postgresql procedure/function, could you provide sample code of how to do this?
Thanks in advance,
Genaro
I have two tables in the same database and same schema. I am writing a program that uses this database in c/c++ using the libpq library. What I need to do now is move SOME data from the first table to the second. By move, I mean that I want the data inserted into the second table and removed from the first (as opposed to just copying it).
My questions are:
1) Is there a faster, better way of doing it other than:
a) insert into table2 select * from table1 where ...
b) delete from table1 where ...
? And if so, how would you do it?
2) Would it be faster to do data moving by executing each command from the c++ code, or would it be faster to create a postgresql procedure or function to do it, and then call it from the c++ code? If it's faster to create a postgresql procedure/function, could you provide sample code of how to do this?
Thanks in advance,
Genaro