VALA PDNS mysql table optimize
Povodny select na tabulku record:
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`147.232.191.6` SQL SECURITY DEFINER VIEW `records` AS select `lmsfin`.`dns_pdns`.`id` + 50 AS `id`,cast(`lmsfin`.`dns_pdns`.`domain_id` as signed) AS `domain_id`,cast(`lmsfin`.`dns_pdns`.`name` as char(255) charset utf8mb4) AS `name`,cast(`lmsfin`.`dns_pdns`.`type` as char(10) charset utf8mb4) AS `type`,cast(`lmsfin`.`dns_pdns`.`content` as char(64000) charset utf8mb4) AS `content`,`lmsfin`.`dns_pdns`.`ttl` AS `ttl`,`lmsfin`.`dns_pdns`.`prio` AS `prio`,`lmsfin`.`dns_pdns`.`change_date` AS `change_date`,`lmsfin`.`dns_pdns`.`disabled` AS `disabled`,cast(`lmsfin`.`dns_pdns`.`ordername` as char(255) charset utf8mb4) AS `ordername`,`lmsfin`.`dns_pdns`.`auth` AS `auth` from `lmsfin`.`dns_pdns` union select `lmsfin`.`nodes`.`id` + 10000 AS `id`,cast((select `lmsfin`.`servis_zona`.`dnszone` AS `dnszone` from `lmsfin`.`servis_zona` where `lmsfin`.`servis_zona`.`seq` = (select `lmsfin`.`customers`.`seq_servis_zona` AS `seq_servis_zona` from `lmsfin`.`customers` where `lmsfin`.`customers`.`id` = `lmsfin`.`nodes`.`ownerid`)) as signed) AS `domain_id`,concat_ws('.',lcase(`lmsfin`.`nodes`.`name`),(select `lmsfin`.`domains`.`name` from `lmsfin`.`domains` where `lmsfin`.`domains`.`id` = (select `lmsfin`.`servis_zona`.`dnszone` AS `dnszone` from `lmsfin`.`servis_zona` where `lmsfin`.`servis_zona`.`seq` = (select `lmsfin`.`customers`.`seq_servis_zona` AS `seq_servis_zona` from `lmsfin`.`customers` where `lmsfin`.`customers`.`id` = `lmsfin`.`nodes`.`ownerid`)))) AS `name`,'A' AS `type`,cast(inet_ntoa(`lmsfin`.`nodes`.`ipaddr`) as char(64000) charset utf8mb4) AS `content`,86400 AS `ttl`,NULL AS `prio`,0 AS `change_date`,0 AS `disabled`,cast(NULL as char(255) charset utf8mb4) AS `ordername`,1 AS `auth` from `lmsfin`.`nodes` where `lmsfin`.`nodes`.`access` = 1 and (select `lmsfin`.`customers`.`status` from `lmsfin`.`customers` where `lmsfin`.`customers`.`id` = `lmsfin`.`nodes`.`ownerid`) <> 1 union select cast(`lmsfin`.`nodes`.`id` as signed) + 1000000 AS `id`,cast(`SPLIT_STRING`(inet_ntoa(`lmsfin`.`nodes`.`ipaddr`),'.',3) as signed) AS `domain_id`,cast(concat_ws('.',`SPLIT_STRING`(inet_ntoa(`lmsfin`.`nodes`.`ipaddr`),'.',4),`SPLIT_STRING`(inet_ntoa(`lmsfin`.`nodes`.`ipaddr`),'.',3),`SPLIT_STRING`(inet_ntoa(`lmsfin`.`nodes`.`ipaddr`),'.',2),`SPLIT_STRING`(inet_ntoa(`lmsfin`.`nodes`.`ipaddr`),'.',1),'in-addr.arpa') as char(255) charset utf8mb4) AS `name`,'PTR' AS `type`,cast(concat(lcase(`lmsfin`.`nodes`.`name`),concat(_utf8'.',(select `lmsfin`.`soa`.`origin` AS `origin` from `lmsfin`.`soa` where `lmsfin`.`soa`.`id` = (select `lmsfin`.`servis_zona`.`dnszone` AS `dnszone` from `lmsfin`.`servis_zona` where `lmsfin`.`servis_zona`.`seq` = (select `lmsfin`.`customers`.`seq_servis_zona` AS `seq_servis_zona` from `lmsfin`.`customers` where `lmsfin`.`customers`.`id` = `lmsfin`.`nodes`.`ownerid`))))) as char(64000) charset utf8mb4) AS `content`,86400 AS `ttl`,NULL AS `prio`,0 AS `change_date`,0 AS `disabled`,cast(NULL as char(255) charset utf8mb4) AS `ordername`,1 AS `auth` from `lmsfin`.`nodes` where `lmsfin`.`nodes`.`access` = 1 and `lmsfin`.`nodes`.`linktype` = 0 and (select `lmsfin`.`customers`.`status` from `lmsfin`.`customers` where `lmsfin`.`customers`.`id` = `lmsfin`.`nodes`.`ownerid`) <> 1 union select `lmsfin`.`soa`.`id` AS `id`,`lmsfin`.`soa`.`id` AS `domain_id`,`lmsfin`.`soa`.`origin` AS `name`,'SOA' AS `type`,concat_ws(' ',`lmsfin`.`soa`.`ns`,`lmsfin`.`soa`.`mbox`,`lmsfin`.`soa`.`serial`,`lmsfin`.`soa`.`refresh`,`lmsfin`.`soa`.`retry`,`lmsfin`.`soa`.`expire`,`lmsfin`.`soa`.`minimum`) AS `content`,`lmsfin`.`soa`.`ttl` AS `ttl`,NULL AS `prio`,0 AS `change_date`,0 AS `disabled`,'' AS `ordername`,1 AS `auth` from `lmsfin`.`soa`
Nova verzia:
select `lmsfin`.`dns_pdns`.`id` + 50 AS `id`,
cast(`lmsfin`.`dns_pdns`.`domain_id` as signed) AS `domain_id`,
cast(`lmsfin`.`dns_pdns`.`name` as char(255) charset utf8mb4) AS `name`,
cast(`lmsfin`.`dns_pdns`.`type` as char(10) charset utf8mb4) AS `type`,
cast(`lmsfin`.`dns_pdns`.`content` as char(64000) charset utf8mb4) AS `content`,
`lmsfin`.`dns_pdns`.`ttl` AS `ttl`,
`lmsfin`.`dns_pdns`.`prio` AS `prio`,
`lmsfin`.`dns_pdns`.`change_date` AS `change_date`,
`lmsfin`.`dns_pdns`.`disabled` AS `disabled`,
cast(`lmsfin`.`dns_pdns`.`ordername` as char(255) charset utf8mb4) AS `ordername`,
`lmsfin`.`dns_pdns`.`auth` AS `auth` from `lmsfin`.`dns_pdns` union
select `lmsfin`.`nodes`.`id` + 10000 AS `id`,
`lmsfin`.`servis_zona`.`dnszone` AS `domain_id`,
concat_ws('.',lcase(`lmsfin`.`nodes`.`name`),`lmsfin`.domains.name) as `name`,
'A' AS `type`,
cast(inet_ntoa(`lmsfin`.`nodes`.`ipaddr`) as char(64000) charset utf8mb4) AS `content`
,86400 AS `ttl`
,NULL AS `prio`
,`lmsfin`.nodes.moddate AS `change_date`,
0 AS `disabled`,
cast(NULL as char(255) charset utf8mb4) AS `ordername`,
1 AS `auth`
from `lmsfin`.nodes
inner join `lmsfin`.customers on `lmsfin`.customers.id = `lmsfin`.nodes.ownerid
inner join `lmsfin`.servis_zona on `lmsfin`.customers.seq_servis_zona = `lmsfin`.servis_zona.seq
inner join `lmsfin`.domains on `lmsfin`.servis_zona.dnszone = `lmsfin`.domains.id
inner join `lmsfin`.passwd on `lmsfin`.passwd.ownerid = `lmsfin`.nodes.ownerid and `lmsfin`.passwd.`expdate` > unix_timestamp()
where `lmsfin`.`nodes`.`access` = 1
union select `lmsfin`.`nodes`.`id` + 1000000 AS `id`,
cast(`SPLIT_STRING`(inet_ntoa(`lmsfin`.`nodes`.`ipaddr`),'.',3) as signed) AS `domain_id`,
cast(concat_ws('.',`SPLIT_STRING`(inet_ntoa(`lmsfin`.`nodes`.`ipaddr`),'.',4),`SPLIT_STRING`(inet_ntoa(`lmsfin`.`nodes`.`ipaddr`),'.',3),`SPLIT_STRING`(inet_ntoa(`lmsfin`.`nodes`.`ipaddr`),'.',2),`SPLIT_STRING`(inet_ntoa(`lmsfin`.`nodes`.`ipaddr`),'.',1),'in-addr.arpa') as char(255) charset utf8mb4) AS `name`,
'PTR' AS `type`,
cast(concat(lcase(`lmsfin`.`nodes`.`name`),concat(_utf8'.',(select `lmsfin`.`soa`.`origin` AS `origin` from `lmsfin`.`soa` where `lmsfin`.`soa`.`id` = `lmsfin`.servis_zona.dnszone ))) as char(64000) charset utf8mb4) AS `content`,
86400 AS `ttl`,
NULL AS `prio`,
`lmsfin`.nodes.moddate AS `change_date`,
0 AS `disabled`,
cast(NULL as char(255) charset utf8mb4) AS `ordername`,1 AS `auth` from `lmsfin`.`nodes`
inner join `lmsfin`.customers on `lmsfin`.customers.id = `lmsfin`.nodes.ownerid
inner join `lmsfin`.servis_zona on `lmsfin`.customers.seq_servis_zona = `lmsfin`.servis_zona.seq
inner join `lmsfin`.domains on `lmsfin`.servis_zona.dnszone = `lmsfin`.domains.id
inner join `lmsfin`.passwd on `lmsfin`.passwd.ownerid = `lmsfin`.nodes.ownerid and `lmsfin`.passwd.`expdate` > unix_timestamp()
where `lmsfin`.`nodes`.`access` = 1
union select `lmsfin`.`soa`.`id` AS `id`,`lmsfin`.`soa`.`id` AS `domain_id`,`lmsfin`.`soa`.`origin` AS `name`,'SOA' AS `type`,concat_ws(' ',`lmsfin`.`soa`.`ns`,`lmsfin`.`soa`.`mbox`,`lmsfin`.`soa`.`serial`,`lmsfin`.`soa`.`refresh`,`lmsfin`.`soa`.`retry`,`lmsfin`.`soa`.`expire`,`lmsfin`.`soa`.`minimum`) AS `content`,`lmsfin`.`soa`.`ttl` AS `ttl`,NULL AS `prio`,0 AS `change_date`,0 AS `disabled`,'' AS `ordername`,1 AS `auth` from `lmsfin`.`soa`