Hello guys, I have a query like this:
$query = Product::query() ->andWhere('some kind of logic') ->orderBy('RAND()') ->limit(10);
But it works so slowly, because it is not optimized and I want to get the following in the context of the Phalcon:
SELECT product.* FROM ( SELECT id FROM product ORDER BY RAND() LIMIT 10 )
AS ids JOIN post ON product.id = ids.id WHERE 'some kind of logic'
Does anyone have any idea how to implement this?