NotORM mix with multiple choices

I looked at this PHP DB library called NotORM , and after reading its documents, I read about its stand at the associations. The argument was mainly the performance of a single SQL query with joins and the use of multiple select queries, and then cross-referencing the results at the DB abstraction level.

I always knew that single queries should always be better than using multiple queries, so the idea of ​​NotORM was new to me. I'm also not sure, because only in NotORM did I see this "function".

I would like to ask you guys about your opinion on this.

Which query is better and faster?

It...

SELECT application.*, tag.* FROM application LEFT JOIN application_tag ON application.id = application_tag.application_id LEFT JOIN tag ON application_tag.tag_id = tag.id ORDER BY application.id 

compared with...

 SELECT * FROM application LIMIT 4; SELECT * FROM application_tag WHERE application_id IN ('1', '2', '3', '4'); SELECT * FROM tag WHERE id IN ('21', '22', '23', '24'); 

Is this second method really practical?

+4
source share
1 answer

I expect one request to be pretty fast. However, this will depend on the connection between php and MySQL. When I tried to compare it, there was noticeable overhead just to fulfill the request (as if simple).

However, if the request becomes too complex, you land on something that is difficult to maintain.

Another thing if you are trying to use any custom procedures. For example, I needed to do some processing based on Levenshtein distances (i.e. Like related words). The MySQL function I found for this was FAR slower than data extraction and processing using the PHP Levenshtein function.

+1
source

Source: https://habr.com/ru/post/1439565/


All Articles