A
A
Anton2016-11-18 20:44:54
MySQL
Anton, 2016-11-18 20:44:54

How to optimize mysql views?

How to optimize views?
THE CODE:

select `A`.`lb0003_id` AS `lb0003_id`,`C`.`lb0101_id` AS `lb0101_id`,`C`.`lb0101_name1` AS `lb0101_name1`,`C`.`lb0101_name2` AS `lb0101_name2`,`C`.`lb0101_name3` AS `lb0101_name3`,`C`.`lb0101_name1_alt` AS `lb0101_name1_alt`,`C`.`lb0101_name2_alt` AS `lb0101_name2_alt`,`C`.`lb0101_name3_alt` AS `lb0101_name3_alt`,`C`.`lb0101_dateOfBirth` AS `lb0101_dateOfBirth`,`C`.`lb0101_idn` AS `lb0101_idn`,`C`.`lb0101_idCard_no` AS `lb0101_idCard_no`,`C`.`lb0101_idCard_dateOfIssue` AS `lb0101_idCard_dateOfIssue`,`C`.`lb0101_idCard_issuedBy` AS `lb0101_idCard_issuedBy`,`C`.`lb0101_idCard_validity` AS `lb0101_idCard_validity`,`C`.`lb0101_passport_no` AS `lb0101_passport_no`,`C`.`lb0101_passport_dateOfIssue` AS `lb0101_passport_dateOfIssue`,`C`.`lb0101_passport_issuedBy` AS `lb0101_passport_issuedBy`,`C`.`lb0101_passport_validity` AS `lb0101_passport_validity`,`C`.`lb0101_location1` AS `lb0101_location1`,`C`.`lb0101_address1` AS `lb0101_address1`,`C`.`lb0101_phone_home` AS `lb0101_phone_home`,`C`.`lb0101_phone_mobile1` AS `lb0101_phone_mobile1`,`C`.`lb0101_phone_mobile2` AS `lb0101_phone_mobile2`,`C`.`lb0101_comments` AS `lb0101_comments`,`C`.`lb0101_email` AS `lb0101_email`,`C`.`lb0101_representative_name` AS `lb0101_representative_name`,`C`.`lb0101_representative_details` AS `lb0101_representative_details`,`C`.`lb0101_created` AS `lb0101_created`,`C`.`lb0101_createdby` AS `lb0101_createdby`,`C`.`lb0101_deleted` AS `lb0101_deleted` from (`ru-rv-od`.`lb0101_client` `C` join `ru-rv-od`.`vw_lb0101_clientbyaccess1cache` `A` on((convert(`A`.`target_lb0003_id` using utf8) = `C`.`lb0101_createdby`)))
union
select `A`.`lb0102_lb0003_id` AS `lb0003_id`,`C`.`lb0101_id` AS `lb0101_id`,`C`.`lb0101_name1` AS `lb0101_name1`,`C`.`lb0101_name2` AS `lb0101_name2`,`C`.`lb0101_name3` AS `lb0101_name3`,`C`.`lb0101_name1_alt` AS `lb0101_name1_alt`,`C`.`lb0101_name2_alt` AS `lb0101_name2_alt`,`C`.`lb0101_name3_alt` AS `lb0101_name3_alt`,`C`.`lb0101_dateOfBirth` AS `lb0101_dateOfBirth`,`C`.`lb0101_idn` AS `lb0101_idn`,`C`.`lb0101_idCard_no` AS `lb0101_idCard_no`,`C`.`lb0101_idCard_dateOfIssue` AS `lb0101_idCard_dateOfIssue`,`C`.`lb0101_idCard_issuedBy` AS `lb0101_idCard_issuedBy`,`C`.`lb0101_idCard_validity` AS `lb0101_idCard_validity`,`C`.`lb0101_passport_no` AS `lb0101_passport_no`,`C`.`lb0101_passport_dateOfIssue` AS `lb0101_passport_dateOfIssue`,`C`.`lb0101_passport_issuedBy` AS `lb0101_passport_issuedBy`,`C`.`lb0101_passport_validity` AS `lb0101_passport_validity`,`C`.`lb0101_location1` AS `lb0101_location1`,`C`.`lb0101_address1` AS `lb0101_address1`,`C`.`lb0101_phone_home` AS `lb0101_phone_home`,`C`.`lb0101_phone_mobile1` AS `lb0101_phone_mobile1`,`C`.`lb0101_phone_mobile2` AS `lb0101_phone_mobile2`,`C`.`lb0101_comments` AS `lb0101_comments`,`C`.`lb0101_email` AS `lb0101_email`,`C`.`lb0101_representative_name` AS `lb0101_representative_name`,`C`.`lb0101_representative_details` AS `lb0101_representative_details`,`C`.`lb0101_created` AS `lb0101_created`,`C`.`lb0101_createdby` AS `lb0101_createdby`,`C`.`lb0101_deleted` AS `lb0101_deleted` from (`ru-rv-od`.`lb0101_client` `C` join `ru-rv-od`.`vw_lb0102_client_access_actual` `A` on((`A`.`lb0102_client_lb0101_id` = `C`.`lb0101_id`)))

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Max, 2016-11-18
@MaxDukov

lay out the EXPLAIN of the query and the description of the tables participating in the query - maybe we will advise something

A
Anton, 2016-11-19
Akhmedaliev @finesoft2009

04f7ae1d4e974239ba504ddb32481d80.png
(ignore the ru-rv-od coloring there, just renamed)
vw_lb0101_clientbyaccess1cache - Table (Display rows 0 - 342 (343 in total, Request took 0.0007 sec.))
vw_lb0102_client_access_actual - View (Display rows 0 - 16 (Display rows 0 - 17 (18 total, Request took 0.0016 sec.))) Size - 16 KiB
EXPLAIN SELECT * FROM `vw_lb0101_clientbyaccess`
e2a6eee3d9524cf886e235279029a892.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question