Forum Discussion
Normalizing Large Fact Tables & Assigning Foreign Keys
Hi there,
I have the following issue. I am working with very heavy fact tables from Google Analytics and Google Ads. String Values such as Unified URL Links and Google Ad Links blow up the size of the table. Following Power BI best practices my goal was to normalize the fact table from all its categorical values and instead create dimensional tables.
- So I created a reference from the google analytics visits table, kept only the column Unified URL and removed all duplicates.
- Following that, I assigned an Index column to the table as a primary key for each URL in the table.
- In the next step I joined the table on the original google analytics table and expanded the new column by the key.
- Last but not least I could remove the column Unified URL from the fact table since I have now the Foreign / Primary Key assigned and could then build the relationship by that key. So far so good.
However, the join of large string values in such large tables (>8.000.000 rows) and the subsequent update of the dataset takes forever (>45 Min for the whole dataset) and makes it very difficult to apply further adjustments.
Does anybody have experiences how to do it better?
1 Reply
- 123abcCommunity Champion
Optimizing the process of normalizing large fact tables and assigning foreign keys can significantly improve performance. Here are some suggestions to make the process more efficient:
Batch Processing:
- Instead of joining the entire dataset at once, consider breaking it into smaller batches and processing them sequentially. This can help reduce memory pressure and improve overall performance.
Indexing:
- Ensure that the columns used for joining and indexing are properly indexed. This can significantly speed up the join operation. In your case, make sure that the columns used for joining, such as the Unified URL, have appropriate indexes.
Data Types:
- Check and optimize the data types of columns. Using more efficient data types can reduce memory usage and improve performance.
Parallel Processing:
- Explore options for parallel processing if your hardware allows. Some operations can be parallelized to take advantage of multi-core processors.
Incremental Load:
- If your data doesn't change frequently, consider implementing an incremental load strategy. Only process the new or modified data since the last update. This can significantly reduce the processing time.
Data Compression:
- Depending on the size of your data, consider compressing it. Compressed data requires less storage and can be processed faster.
Filtering:
- Before joining, filter out unnecessary data. If you have criteria to exclude certain rows, apply these filters early in the process to reduce the amount of data that needs to be processed.
Use Proper Join Algorithms:
- Depending on the database or tool you are using, explore and use the most efficient join algorithms. Some databases have optimizations for specific join types.
Materialized Views or Aggregations:
- Consider creating materialized views or pre-aggregated tables for frequently used queries. This can reduce the need for recalculating aggregations during query time.
Memory Management:
- Ensure that your system has sufficient memory available for the operations. Adjust memory settings if needed.
Evaluate Hardware:
- If possible, evaluate the hardware on which the database or Power BI is running. Upgrading hardware, if feasible, can have a significant impact on performance.
Remember to test these optimizations in a controlled environment to ensure they have the desired impact without causing any issues. It's also a good idea to monitor resource usage during the process to identify any bottlenecks.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.