I
I
Ivan Koryukov2015-11-04 18:15:36
PHP
Ivan Koryukov, 2015-11-04 18:15:36

How to make friends with the object approach of interaction with the database and resource-intensive analytics?

Reading M. Fowler, I began to think that DataMapper is a kind of standard for interacting with the database in object-oriented languages. And everything is fine in it, but, for example, in one of my projects, there are a lot of reports, and now almost every report is querying with JOIN.
The project is being rewritten to the OOP and soon it will come to these same reports. The speed of their generation already left much to be desired, and now it should generally fall.
You cannot leave these queries as they are - reports use the logic of the subject area, which is written in models and cannot be applied to raw data.
So far, I think that for reports it is necessary to apply a different approach - to calculate the report values ​​using the same models, but write the result in separate tables. Accordingly, the calculations should be carried out on the crown once every N hours, and the report should be given from the table.
Maybe there are other ways?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Flaker, 2015-11-04
@Flaker

In fact, IMHO, in order to achieve the maximum speed of generating reports on request, you just need to stop generating them on request.
Generate ahead of time.
Concerning DataMapper: Productivity sags usually at a large number of records. Of course, this pattern adds +1 level of abstraction by allowing you not to work directly with SQL. You can always do without it.

S
Sergey, 2015-11-04
Protko @Fesor

CQRS , DataMapper for writing (easy to maintain, relatively slow for writing and reading, very slow with complex queries), data aggregation for reading (easy to maintain, fast for reading)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question