Robert van Boesschoten
Last updated: 27-08-2020
In this article we will show you some of the most common parts of your application which could use some improvement. Improving performance is more critical than ever. Our always-on, hyper connected end users demand blazing fast experiences. The Betty Blocks platform facilitates certain performance improvements out of the box, others have to be implemented by the developer.
Try to avoid the use of expression properties as much as possible. Every time a dependent property is changed, the expression will be recalculated in the background resulting in a longer waiting time for background actions. In some cases it is better to calculate a value by using a before or after save action instead of using an expression.
Try to avoid the use of expression properties on models where records are imported via large CSV or XLSX files. For each record that is imported the expressions for that record will be recalculated, resulting in a very large waiting time.
When you've got an expression property that uses a property from another model, every time one of the properties of the other model is changed, your expression will be triggered as well. For example, when you have invoice.price, invoice.vat_price and invoice.total_price that are all sums of the invoice_items, every time you add or change an invoice item for that invoice it will trigger the expressions on the invoice as well. So when you've got 100 invoice items on one invoice, about 300 expression properties will be triggered.
Try to avoid this by calculating the prices of the invoice using an action that is called after adding all of the invoice items. The calculation will be done only once instead of 100 times which is far more efficient.
Every time you do a create or update event in an action, you can specify which triggered actions should be skipped. Try to skip as many as possible if they are not of use in that specific create or update event.
This is very inefficient and even triggers the same after_save action again, potentially resulting in an infinite loop. Instead, try to use before_save action with an assign event. This will trigger no extra database save actions and model actions.
This may be the easiest setting to apply. While the Betty Blocks platform is only becoming faster, Liquid is not. When collecting a lot of data from your database on your page, loading times on your page will increase. By enabling caching, the first visit of the page will cache a lot of data in your browser. This results in shorter loading times when visiting this page at a later time.
Go through all your models and make sure the checkbox “Index Values” is checked on the right properties. You should also check your application log for adding indexes. Your application will log warn messages indicating a search is done on an unindexed property and you should try to add an index. Indices are increasing search performance on that specific property. Unless updating or creating records is the performance bottleneck, don’t hesitate to add up to 20 indexes per model.
This mostly applies to datamodels with many properties. Multi Line text properties tend to slow down database queries.
Below, you can find a checklist with the first things to check when improving your application performance.
On slow models, minimize the use of Multi Line text properties, they tend to slow down database queries.