The maximum row size for an InnoDB table, which applies to data stored locally within a database page, is slightly less than half a page for 4KB, 8KB, 16KB, and 32KB innodb_page_size settings.
user_id соответсвует количеству зарегистрированных клиентов и написал следующий кодНеудачное решение. Нет никаких гарантий, что id будут идти строго последовательно.
WITH RECURSIVE `dates` (`date`) AS (
SELECT '2021-06-01'
UNION
SELECT `date` + INTERVAL 1 DAY
FROM `dates`
WHERE `date` < '2021-06-30'
)
SELECT `d`.`date`, MAX(`c`.`count`) OVER `win` AS `registered`
FROM `dates` AS `d`
LEFT JOIN (
SELECT DISTINCT `date`, COUNT(*) OVER `win` AS `count`
FROM `registers`
WINDOW `win` AS (ORDER BY `date`)
) AS `c` ON `c`.`date` = `d`.`date`
WINDOW `win` AS (ORDER BY `d`.`date`)
WITH RECURSIVE `cte` (`date`) AS (
SELECT :from_date
UNION
SELECT `date` + INTERVAL 1 DAY
FROM `cte`
WHERE `date` < :to_date
)
SELECT `cte`.`date`,
IFNULL(`s`.`count`, 0) AS `joined_count`,
IFNULL(`u`.`count`, 0) AS `left_count`
FROM `cte`
LEFT JOIN (
SELECT `joined_date`, COUNT(*) AS `count`
FROM `table`
WHERE `joined_date` BETWEEN :from_date AND :to_date
GROUP BY `joined_date`
) AS `s` ON `s`.`joined_date` = `cte`.`date`
LEFT JOIN (
SELECT `left_date`, COUNT(*) AS `count`
FROM `table`
WHERE `left_date` BETWEEN :from_date AND :to_date
GROUP BY `left_date`
) AS `u` ON `u`.`left_date` = `cte`.`date`
If the ONLY_FULL_GROUP_BY SQL mode is enabled (which it is by default), MySQL rejects queries for which the select list, HAVING condition, or ORDER BY list refer to nonaggregated columns that are neither named in the GROUP BY clause nor are functionally dependent on them.
MySQL also permits a nonaggregate column not named in a GROUP BY clause when SQL ONLY_FULL_GROUP_BY mode is enabled, provided that this column is limited to a single value
mysqli_report(MYSQLI_REPORT_OFF);
, либо, что более правильно, использовать try ... catch.WITH `cte` (`id`, `price`, `date`, `row`) AS (
SELECT `good`, `price`, `date`, ROW_NUMBER() OVER `win`
FROM `item_good_supplies`
WHERE `good` IN('23068', '21805', '23204', '22493', '21813', '21802', '23845')
WINDOW `win` AS (
PARTITION BY `good`
ORDER BY `date` DESC
)
)
SELECT `id`, `price`, `date`
FROM `cte`
WHERE `row` = 1