G
G
Glory2022-02-21 16:52:31
Laravel
Glory, 2022-02-21 16:52:31

Where is the best place to keep fields that change frequently? balances, prices. Separately?

In laravel, a product model was created from a large number of fields. At the same time, most of the fields almost never change, except when the product appears on the site.
In this model, there used to be a price, currency field, and this was taken out separately. price updates started going faster.

But there are also such fields as Published, in stock - this is in this entity
, and there is also a related entity - this is a group of goods. it also has the fields "published", "in stock" as well as min and max price and min and max prices are recalculated every time when the price changes in any product associated with its group.

In general, what I'm getting at. I also want to put the fields that change often into a separate table and change only these tables when importing goods or when editing manually. so it will work faster. than to work with the table in which 50-60 fields? Or does it make no sense?

Why Laravel - it's just that Laravel has a functionality that conveniently pulls data from related entities through the with construct, but in the end you get a related array. otherwise, you will have to do a left join, and this will slow down the work with the goods. Joins slow down the speed of the query. But is it strong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FanatPHP, 2022-02-21
@FanatPHP

It makes no sense

V
Vyacheslav Plisko, 2022-02-22
@AmdY

In principle, a normal option, a bunch of business logic and indexes that are updated can be hung on the main entity. This will make it easier to insert, but harder to update and read, especially with sort filters on related tables.
The main thing is not to forget to use with() so that the relays are loaded with one additional request, and not for each call.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question