D
D
Diversia2021-01-27 17:24:01
1C-Bitrix
Diversia, 2021-01-27 17:24:01

How to reduce query execution time with LOGIC filter?

Hello.

There is a component in which getList is executed with a LOGIC filter. Is it possible in this case to somehow change the filter for faster execution?

$arFilter = array(
      "IBLOCK_ID" => 1,
      array(
        "LOGIC" => "OR",
        array("PROPERTY_actors" => $arResult["ID"]),
        array("PROPERTY_actorsMain" => $arResult["ID"]),
        array("PROPERTY_writer" => $arResult["ID"]),
        array("PROPERTY_director" => $arResult["ID"]),
      ),
    );

    $rsElement = CIBlockElement::GetList(Array("PROPERTY_dateStart" => "DESC"), $arFilter, false, Array(), $arSelect);

601176e5652fb196903936.jpeg

I guess it's because of multiple JOINs:
LEFT JOIN b_iblock_property FP0 ON FP0.IBLOCK_ID = B.ID AND FP0.CODE='ACTORS'

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Diversia, 2021-03-19
@Diversia

Disabling sorting and select did not help. Only the restructuring of the sampling logic helped. Added a separate field that included all the elements for which the filter was true. The sample earned ~10 times faster.

A
Andrey Slashchinin, 2021-01-31
@slashinin

Most likely it's not about joins, but about filtering and sorting.
To optimize the query, try temporarily removing the sort and the $arSelect array and see if there are any changes.
It is also worth finding out if there are indexes in MySQL.
Bitrix admin panel has a page with information about indexes.
You can also try to transfer the infoblock data to a separate table (this option is available in the infoblock settings) and look at the indexes in the new table with the infoblock and if they are not there, create them yourself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question