The following are scenarios where the EDB Advances Storage Pack TAMs are useful.
Refdata example
A scenario where Refdata is useful is when creating a reference table of all the New York Stock Exchange (NYSE) stock symbols and their corporate names. This data is expected to change very rarely and be referenced frequently from a table tracking all stock trades for the entire market (like in the Advanced Autocluster example). You can use Refdata instead of heap to increase performance.
Autocluster example
A scenario where Autocluster is useful is with Internet of Things (IoT) data, which are usually inserted with many rows that relate to each other and often use append-only data. When using heap instead of Autocluster, Postgres can't cluster together these related rows, so access to the set of rows touches many data blocks, can be very slow, and is input/output heavy.
This example is for an IoT thermostat that reports house temperatures and temperature settings every 60 seconds:
Using Autocluster, rows with the same thermostat_id are clustered together and are easier to access:
Note
The cols parameter specifies which table is clustered. In this case, {1} corresponds to the first column of the table, thermostat_id, which is the most common access pattern.
Populate the table with the thermostat_id and recordtime data:
When you select the data from the IoT table, you can see from the ctid location that the data with the same thermostat_id was clustered together:
Advanced example
This is an advanced example where Refdata and Autocluster are used together. It involves referencing the NYSE table from the Refdata example and clustering together the rows based on the stock symbol. This approach makes it easier to find the latest number of trades.
Start with the NYSE table from the Refdata example:
Create a highly updated table containing NYSE trades, referencing the mostly static stock symbols in the Refdata table. Cluster the rows on the stock symbol to make it easier to look up the last x trades for a given stock:
Create a view to facilitate inserting by symbol name rather than id: