чтобы он выполнялся быстрее?
# 1.1s user time, 80ms system time, 29.68M rss, 34.79M vsz # Current date: Mon Nov 13 12:05:20 2023 # Hostname: logstorage2.beget.ru # Files: /dev/fd/63 # Overall: 22 total, 2 unique, 0.00 QPS, 0.00x concurrency ___ # Time range: 2023-11-11T22:26:19 to 2023-11-12T20:50:34 # Attribute total min max avg 95% stddev median # ============ ======= ======= ======= ======= ======= ======= ======= # Exec time 48s 2s 3s 2s 2s 136ms 2s # Lock time 1ms 33us 75us 49us 63us 11us 48us # Rows sent 127 1 6 5.77 5.75 0.99 5.75 # Rows examine 58.37M 2.61M 2.66M 2.65M 2.62M 24.30k 2.62M # Rows affecte 0 0 0 0 0 0 0 # Bytes sent 4.83k 72 232 224.73 223.14 32.07 223.14 # Query size 8.60k 135 413 400.36 400.73 56.30 400.73 # Profile # Rank Query ID Response time Calls R/Call V/M I # ==== ================================ ============= ===== ====== ===== = # 1 0x03DDF95CD75FDCDEA5E8C89D4BA... 45.3928 95.1% 21 2.1616 0.01 SELECT cars visits # MISC 0xMISC 2.3372 4.9% 1 2.3372 0.0 <1 ITEMS> # Query 1: 0.00 QPS, 0.00x concurrency, ID 0x03DDF95CD75FDCDEA5E8C89D4BA01F3A at byte 1172671 # This item is included in the report because it matches --limit. # Scores: V/M = 0.01 # Time range: 2023-11-11T22:26:19 to 2023-11-12T20:50:34 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 95 21 # Exec time 95 45s 2s 3s 2s 2s 135ms 2s # Lock time 94 1ms 33us 75us 49us 63us 11us 44us # Rows sent 99 126 6 6 6 6 0 6 # Rows examine 95 55.76M 2.65M 2.66M 2.66M 2.62M 0 2.62M # Rows affecte 0 0 0 0 0 0 0 0 # Bytes sent 98 4.76k 232 232 232 232 0 232 # Query size 98 8.47k 413 413 413 413 0 413 # String: # Databases fritsc5q_pravda # Hosts localhost # Last errno 0 # Users fritsc5q_pravda # Query_time distribution # 1us # 10us # 100us # 1ms # 10ms # 100ms # 1s ################################################################ # 10s+ # Tables # SHOW TABLE STATUS FROM fritsc5q_pravda LIKE 'cars'\G # SHOW CREATE TABLE fritsc5q_pravda.cars\G # SHOW TABLE STATUS FROM fritsc5q_pravda LIKE 'visits'\G # SHOW CREATE TABLE fritsc5q_pravda.visits\G # EXPLAIN /*!50100 PARTITIONS*/ select cars.id, t_cars.t_visits from cars inner join (SELECT page_id, COUNT(user_ip) as t_visits FROM visits GROUP BY page_id) as t_cars on t_cars.page_id = cars.id where cars.country = "GE" AND (cars.status = "verify" OR cars.status = "publish") AND cars.created_at BETWEEN DATE_ADD(CURRENT_DATE, INTERVAL -7 DAY) AND CURRENT_DATE and cars.deleted_at is null order by t_cars.t_visits DESC limit 6\G
Оформи как нибудь нормально запрос, explain и show create table
НАверное так всё же будет лучше select cars.id, COUNT(t_cars.user_ip) as t_visits from cars inner join visits as t_cars on t_cars.page_id = cars.id where cars.country = "GE" AND (cars.status = "verify" OR cars.status = "publish") AND cars.created_at BETWEEN DATE_ADD(CURRENT_DATE, INTERVAL -7 DAY) AND CURRENT_DATE and cars.deleted_at is null GROUP BY cars.id order by t_cars.t_visits DESC limit 6
Обсуждают сегодня