Anyname Donotcare
Anyname Donotcare

Reputation: 11403

How to transfer data from SQL Server to Informix and vice versa

I want to transfer tables data from SQL server to Informix and vice versa.

The transferring should be run scheduled and sometimes when the user make a specific action.

I do this operation through delete and insert transactions and it takes along long time through the web between 15 minute to 30 minute.

How to do this operation in easy way taking the performance in consideration?


Say I have

Vacation table in SQL Server and want to transfer all the updated data to the Vacation table in Informix.

and

Permission table in Informix and want to transfer all the updated data to the Permission table in SQL Server.


Upvotes: 2

Views: 1487

Answers (2)

Nigel Tufnel
Nigel Tufnel

Reputation: 418

DISCLAIMER: I am not an SQL Server DBA. However, I have been an Informix DBA for over ten years and can make some recommendations as to its performance.

Disclaimer aside, it sounds like you already have a functional application, but the performance is a show-stopper and that is where you are mainly looking for advice.

There are some technical pieces of information that would be helpful to know, but in their absence, I'm going to make the following assumptions about your environment and application. Please comment or edit your question if I am wrong on any of these.

  1. Database server versions. From the tags, it appears you are using SQL server 2012. However, I cannot determine the Informix server and version. I will assume you are running at least IDS 11.50 or greater.
  2. How the data is being exchanged currently. Are you connecting directly from your .NET application to Informix? I would assume that is the case with SQL Server and will make the same assumption for your Informix connection as well.
  3. Table structures. I assume you have proper indexing on the tables. On the Informix side, dbschema -d *dbname* -t *tablename* will give the basic schema.

If you haven't tried exporting data to CSV and as long as you don't have any compliance concerns doing this, I would suggest loading the data from a comma-delimited file. (Informix normally deals with pipe-delimited files, so you'll either need to adjust the delimiter on the SQL Server side to a pipe | or on the Informix import side). On the Informix end, this would be a

LOAD FROM 'source_file_from_sql_server' DELIMITER '|' INSERT INTO vacation (field1, field2, ..)

For reusability, I would recommend putting this in a stored procedure. Just wrap that load statement inside a BEGIN WORK; and COMMIT WORK; to keep your transactional integrity. Michał Niklas suggested some ways to track changes. If there is any correlation between the transfer of data to the vacation table in Informix and the permission table back in SQL Server, I would propose another option, which is adding a trigger to the vacation table so that you write all new values to a staging table.

With the import logic in a stored procedure, you can fire the import on demand:

EXECUTE PROCEDURE vacation_import();

You also mentioned the need to schedule the import, which can be accomplished with Informix's "dbcron". Using this feature, you'll create a scheduled task that executes vacation_import() periodically as well. If you haven't used this feature before, using OAT will be helpful. You will also want to do some housekeeping with the CSV files. This can be addressed with the system() call, which you can make from stored procedures in Informix.

Upvotes: 2

Michał Niklas
Michał Niklas

Reputation: 54302

Some ideas:

  1. Add was_transferred column to source tables setting its default value to 0 (you can use 0/1 instead of false/true).

  2. From source table select data with was_transferred=0.

  3. After transferring data update selected source row, set its was_transferred to 1.

  4. Make table syncro_info with fields like date_start and date_stop. If you discover that there is record with date_stop IS NULL it will mean that you are tranferring data. This will protect you against synchronizing data twice.

Upvotes: 1

Related Questions