'Are views on near real time data warehouse a good idea?
We have near real time datawarehouse in sql server which is updating every 3-4 mints. I really wanted to have an idea if creating views on these tables(or joining these tables) would be a good idea as they are getting updated every 2-3 minutes. And would indexing these views or tables help in performance?
I just wanted a general view on this please.
The table size varies from 5-10gb and every update on each table usually contains about 100 new row updates sizing a few mbs.
Solution 1:[1]
You can filter the toSortArray based upon each of the sortingArray element values. Using filter will return an array of one element that matches the current value. Since filter returns an array, use flatMap() to iterate over the sortingArray and return a single, sorted array in the order of the sortingArray.
const toSortArray = [{taskID: 1, "title": "something1", subtasks: {}},
{taskID: 5, "title": "something5", subtasks: {}},
{taskID: 8, "title": "something8", subtasks: {}}];
const sortingArray = [8, 1, 5];
const result = sortingArray.flatMap(so=>toSortArray.filter(ts=>ts.taskID === so));
console.log(result);
Solution 2:[2]
You can use map and find as:
toSortArray = [{ taskID: 1, "title": "something1", subtasks: {} },
{ taskID: 5, "title": "something5", subtasks: {} },
{ taskID: 8, "title": "something8", subtasks: {} }];
sortingArray = [8, 1, 5];
const result = sortingArray.map((item) => toSortArray.find((element) => element.taskID === item));
console.log(result);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Randy Casburn |
| Solution 2 | Özgür Murat Sağdıçoğlu |
