A
A
Anton Shelestov2019-04-11 20:55:47
MySQL
Anton Shelestov, 2019-04-11 20:55:47

Is it possible to see how the sql query is processed?

Hello!
Perhaps the question is stupid, but I'm wondering if it's possible to somehow see how the request works, step by step.
Those. traversing tables, executing nested selects, exists, etc.
There is this request:

SELECT
    `profiles`.*,
    `edu_speciality_profile`.`edu_speciality_id` AS `pivot_edu_speciality_id`,
    `edu_speciality_profile`.`profile_id` AS `pivot_profile_id`,
    `edu_speciality_profile`.`id` AS `pivot_id`,
    `edu_speciality_profile`.`max_year` AS `pivot_max_year`
FROM
    `profiles`
INNER JOIN `edu_speciality_profile` ON `profiles`.`id` = `edu_speciality_profile`.`profile_id`
WHERE
    `edu_speciality_profile`.`edu_speciality_id` IN(1) AND EXISTS(
    SELECT
        *
    FROM
        `edu_speciality_profile_year`
    INNER JOIN `edu_speciality_profile` ON `edu_speciality_profile`.`id` = `edu_speciality_profile_year`.`edu_speciality_profile_id`
    WHERE
        `profiles`.`id` = `edu_speciality_profile`.`profile_id` AND `edu_speciality_profile`.`max_year` = `edu_speciality_profile_year`.`year` AND `edu_speciality_profile_year`.`distant` = 1
);

And for this query, WHERE EXISTS does not work out as intended ...
If you are interested in what exactly the query does, I can describe it, everything is complicated there))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Immortal_pony, 2019-04-11
@ShelestovAnt

EXPLAIN - https://dev.mysql.com/doc/refman/8.0/en/explain.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question