R
R
run1822020-12-28 20:58:58
1C-Bitrix
run182, 2020-12-28 20:58:58

Which is better - one big or many small SQL queries?

There is an infoblock, it has approx. 300 sections. It is necessary to pull out all the sections and the number of elements from them from the infoblock. There are 2 ways:
1) One request through CIblockSection, specifying ELEMENT_CNT
2) One request for CIblockElement without ELEMENT_CNT and for each section do CIblockElement::GetList()->SelectedRowsCount()

The first method takes 1.2 seconds.
Second in 0.7 sec.

It turns out that the second request is faster. But is it always like this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2020-12-29
@run182

Relational database queries in the "evil" loop!
When I was engaged in deep optimization of Bitrix for 200k products and more than 1000 properties, all such pearls had to be removed.
In your case, immediately get the section IDs of elements with grouping, so as not to go into the database with direct queries, use D7, there is a querybuilder

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question