Select columns to transfer to SQL Server from Exact Online

If I read this correctly, I see two requirements:

  • vertical filtering: pulling less data from 1 table within 1 administration/partition.
  • horizontal filtering: pulling fewer columns from 1 table.

At the moment this is possible with Invantive Data Replicator, but it requires creating an in-memory table, for example:

create or replace table vert_en_horz_gefilterd@inmemorystorage
as
select column1
,      column2
,      ...
,      column50
--
-- Horizontal filter.
-- Skip remaining columns: column51...column75.
--
from   exactonlinerest..salesinvoicesbulk
--
-- Vertical filter: created this or last month.
--
where  created >= add_months(trunc(sysdateutc, -1), -1)

By default, in-memory tables are not materialised when you read them, in other words:

select count(*)
from   vert_en_horz_gefilterd@inmemorystorage

only returns the row count, but does not update the replica. From a replication perspective, in-memory tables are considered extremely fast and reliable, so replication is not needed.

However, you can force it with an Invantive SQL ods hint:

select /*+ ods(true, interval '0 seconds') */
       count(*)
from   vert_en_horz_gefilterd@inmemorystorage

You can find an explanation of the ods hint in the grammar.

The query now takes a bit longer because it writes the replica to the backing database (usually SQL Server).

Are there any drawbacks to this approach?

Yes, depending on your use case. The biggest drawback, in my view, is that if you have multiple partitions/administrations, all administrations suddenly become 1 partition. The in-memory table is not partitioned. You do neatly have a division column, for example on Exact Online, but the data is replaced entirely for all partitions at once. If you handle, say, 500 partitions this way at once, it also means that 1 failing partition blocks the refresh of the rest. For businesses with a few dozen administrations this won’t be an issue, but a larger office may well run into trouble with it.

In addition, the in-memory table also needs to fit in memory. Invantive SQL usually runs in 64-bit, but in-memory tables much larger than a few dozen gigabytes often cause issues because, for certain parts, for example, 1 field’s content still cannot exceed 2..4 GB. Usually this isn’t much of a problem; Invantive SQL has a very aggressive algorithm for sharing and compressing data within result sets (both binary data and text), so memory usage is often remarkably low for large result sets.

Finally, I myself only have experience with this way of working on tables using the copy scenario. Trickle loading becomes difficult. Perhaps it’s possible, but I’ve never worked it out myself on a serious production system.

I do often see the described way of working on platforms that have many table functions, such as NMBRS, Loket or Visma net. In Invantive SQL, views are then often created containing Invantive SQL queries or entirely hand-written algorithms, but you often can’t avoid a separate SQL statement. I expect that at some point we’ll add user-defined views that will then be stored in a data dictionary, but at the moment all views are hard-coded or they reside in a startup SQL, such as on Invantive Cloud.

If the focus isn’t so much on functionality, but rather on the amount of storage needed on the backing database, you could also opt for database compression. The content of dcd and dcs is chosen in such a way that you can, for example, enable compression on SQL Server. This is also one of the reasons why we so often try to set a maximum length on a field, even if nothing is described about it in the API specification.

More explanation in English can be found at Limit columns or rows replicated to SQL Server.

Elsewhere you can read more about SQL Server (page) compression.

In general, the advice is therefore:

  • Use as many standard features as possible, including hard-coded views; this is cheap, reliable and scales well.
  • If that takes up too much space, use native database compression.
  • If that doesn’t work well enough, use an in-memory table with a query.
  • If that doesn’t work well enough, write the replication using features such as Invantive PSQL, synchronize, union distinct on.

As you go down the list, you can influence ever more parts of the process, but it also costs more and more working hours and maintenance.

Regarding WarehouseTransferLines based on the XML API, I recommend:

  • first check whether there’s a REST version of it at Exact Online Data Model - Invantive
  • if not, do an F4 from the Invantive Query Tool and pass on the number of columns via a support ticket. Invantive will then look into whether we can limit the number. The Exact Online XSD namely contains quite a lot of XML paths for which, as far as is known, no content is returned.