Looking for ways to enhance performance and efficiency, specifically where database queries are concerned? If you are working within Logi applications, there are many ways we can leverage data to dynamically drive part of the application, or to cache and re-use data sets. Here are some best practices to consider when using data layers:
First things first. A data layer is a set of information that exists on a page – hidden in the code and invisible to the human eye. In Logi, data layers are what we use to determine what will be displayed in a report or dashboard. Not only is this used for things like data tables or charts, but any other dynamic content. They can also simple or complex.
Now onto best practices:
Using local data layers – Local data layers run before anything else in a report, and can be used anywhere in a report. These help drive things that you wouldn’t typically bind to its own query (like a title on a page). This gives you access to have data-driven components where you ordinarily wouldn’t have them and gives you control over the order you want to run them in (result of one query may be used to drive another).
Using linked data layers – Oftentimes multiple places in a report requires you to utilize the same set of data. Linked data layers allow you to reuse a data set without having to re-query it. So instead of issuing the same query to the database multiple times, you can reuse the same set of data by building it in one location and pulling it once. This helps maximize performance, minimize database queries and gives you a nice single place to update that query if and when a change is needed.
Caching data layers – Similar to linked data layers, caching data layers means you don’t have to re-query data. Imagine a data set that is pretty static. By caching it, the data will only pull once in a specified period of time. For example, that weekly report you rely on? Caching allows us to easily provide the results to everyone without having to recalculate it every time. These can also be stacked together at different levels, so different components of the data can be cached at different intervals and refreshed as needed – meaning the most important data is always up to date!
Utilizing these powerful tips and abilities early on can help you figure out how to prep and prepare your data when you need to run a report or series of reports. Doing this not only makes it quicker to query your data but also gives you a powerful toolset when building applications. It’s also a good technique for developers who want to reduce the number of data layer queries they need to run!