powered by simpleCommunicator - 2.0.18     © 2024 Programmizd 02
Map
Форумы / Вопросы по форуму [закрыт для гостей] / Долгое открытие маленьких подфорумов на рескуле, Поиск: Искать сообщения, созданные автором: basename  
25 сообщений из 32, страница 1 из 2
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536264
basename
Скрыть профиль Поместить в игнор-лист
Участник
Долгое открытие подфорумов с большим количеством тем
Цитата 
[игнорируется]
По поводу запросов. Выполняя один и тот же запрос, но просто с разными ID форума четко вижу что оптимизатор выбирает разные планы в зависимости от форума. Без хинтов он лагает с выбором хорошего плана для ПТ.

С хинтами такое дело, они пригвоздают к опредленному пути, который не всегда оптимален.

В общем у меня есть запрос, который хорошо работает на форумах ПТ, MS SQL и Oracle, но плохо на маленьких форумах.

У меня есть запрос, который хорошо работает на форумах ПТ и на маленьких форумах, но плохо на MS SQL и Oracle.

Получается дилемма либо либо.

Без хитов оптимайзер не всегда выбирает правильный. С хинтами привгождает в плану который не всегда оптимален.
Я восстанавливаю текущий бэкап. Запущу оптимизацию таблицы, возможно после этого оптимайзер будет более эффективно выбирать планы.
Цитата 
[игнорируется]
Оптимизация таблицы не помогла. В общем лучшее решение это запрос где маленькие и ПТ работают быстро а оракл или ms sql в пределах секунды. Кодить что то, типа if forum == 46 такой запрос иначе такой колхоз и не унивесально. Видимо тут уже данные так размазаны по таблице. ПТ импортил я и он лежит кучно потому что занимал 90% всех данных, а оракл и ms sql сильно размазаны видимо на сбор тратися больше времени. Самое обидное что с хинтом они работают быстро, т.е. алгоритм эффектиный для них есть но оптимайзер его не вкуривает. А если использовать хинт он портит запрос для других форумов.
Ну сейчас так:
- подфорум из 12 тем открывается 6 секунд
- подфорум из 1 темы открывается 1 секунду
- подфорум из 300 000 тем открываестя 200 ms
- всё остальное, что больше 100 тем тоже впоне приемлемо быстро.

Деда подобрал запросы:
- мелкие и сравнительно очень большие быстро
- средние - в пределах секунды

Средние - это большинство проффорумов.
...
Рейтинг: 1 / 0
Нравится: Гарыныч
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536268
basename
Скрыть профиль Поместить в игнор-лист
Участник
basename  12.09.2023, 12:55
[игнорируется]
Долгое открытие подфорумов с большим количеством тем
Цитата 
[игнорируется]
По поводу запросов. Выполняя один и тот же запрос, но просто с разными ID форума четко вижу что оптимизатор выбирает разные планы в зависимости от форума. Без хинтов он лагает с выбором хорошего плана для ПТ.

С хинтами такое дело, они пригвоздают к опредленному пути, который не всегда оптимален.

В общем у меня есть запрос, который хорошо работает на форумах ПТ, MS SQL и Oracle, но плохо на маленьких форумах.

У меня есть запрос, который хорошо работает на форумах ПТ и на маленьких форумах, но плохо на MS SQL и Oracle.

Получается дилемма либо либо.

Без хитов оптимайзер не всегда выбирает правильный. С хинтами привгождает в плану который не всегда оптимален.
Я восстанавливаю текущий бэкап. Запущу оптимизацию таблицы, возможно после этого оптимайзер будет более эффективно выбирать планы.
Цитата 
[игнорируется]
Оптимизация таблицы не помогла. В общем лучшее решение это запрос где маленькие и ПТ работают быстро а оракл или ms sql в пределах секунды. Кодить что то, типа if forum == 46 такой запрос иначе такой колхоз и не унивесально. Видимо тут уже данные так размазаны по таблице. ПТ импортил я и он лежит кучно потому что занимал 90% всех данных, а оракл и ms sql сильно размазаны видимо на сбор тратися больше времени. Самое обидное что с хинтом они работают быстро, т.е. алгоритм эффектиный для них есть но оптимайзер его не вкуривает. А если использовать хинт он портит запрос для других форумов.
Ну сейчас так:
- подфорум из 12 тем открывается 6 секунд
- подфорум из 1 темы открывается 1 секунду
- подфорум из 300 000 тем открываестя 200 ms
- всё остальное, что больше 100 тем тоже впоне приемлемо быстро.

Деда подобрал запросы:
- мелкие и сравнительно очень большие быстро
- средние - в пределах секунды

Средние - это большинство проффорумов.
Но 6 секунд на подфорум из 12 тем - это конечно пздц уже напряжно.
...
Рейтинг: 0 / 0
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536284
basename
Скрыть профиль Поместить в игнор-лист
Участник
eNose  12.09.2023, 12:58
[игнорируется]
раз деда насобирал такую статистику, то самое время впендюрить запросы в отдельную таблицу базы и брать оптимальный по id форума

либо хинты в базу кидануть и в зависимости от форума подправлять запрос
ну там выше дедоответ. Городить жесткие костыли, с привязкой к конкретному форум, он не хочет. Ну и это логично и неправильно.

Что любопытно, на этом форуме тот же код, та же субд, та же структура БД и т.п. и таких проблем нет.
...
Рейтинг: 0 / 0
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536287
basename
Скрыть профиль Поместить в игнор-лист
Участник
IT-Клоп  12.09.2023, 13:03
[игнорируется]
Деда, помнится, совместимость с MS SQL держал.
Тока там хостинг будет дорогой.
Этот уже тоже не дешевый. Примерно ~12 000
...
Рейтинг: 0 / 0
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536300
basename
Скрыть профиль Поместить в игнор-лист
Участник
eNose  12.09.2023, 13:01
[игнорируется]
и вообще хули вы хотите от оптимизатора халявной субд?

переходите на мсскульсервер или на орацле - там таких глюком меньше (но там есть другие!)
оракле платное же
...
Рейтинг: 0 / 0
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536384
basename
Скрыть профиль Поместить в игнор-лист
Участник
eNose  12.09.2023, 13:56
[игнорируется]
basename  12.09.2023, 12:55
[игнорируется]
Ну сейчас так:
- подфорум из 12 тем открывается 6 секунд
- подфорум из 1 темы открывается 1 секунду
- подфорум из 300 000 тем открываестя 200 ms
- всё остальное, что больше 100 тем тоже впоне приемлемо быстро.
дело в паджинации, это ж очевидно

для проверки пусть поставит 10 тем на страницу и посмотрит сколько будет открываться форум с 12 темами
Ответ деды:
Цитата 
[игнорируется]
Паджинация зло, да. Сейчас рулит ленивая подгрузка по мере скроллинга, но как мы видим есть хорошие алгоритмы для получения списка тем первых страниц. У ПТ дохера страниц но первая грузится быстро сейчас. Проблема в другом - оптимайзер иногда не рюхает как надо, а хинты наоборот сбивают отпитмайзер в некоторых других случаях.
Цитата 
[игнорируется]
Возможно они предложат вариант переписывания запроса который без хинтов работает всегда хорошо. Я пока не нащупал такой комбинации.
...
Рейтинг: 0 / 0
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536396
basename
Скрыть профиль Поместить в игнор-лист
Участник
Гарыныч  12.09.2023, 14:25
[игнорируется]
basename  12.09.2023, 12:58
[игнорируется]
Но 6 секунд на подфорум из 12 тем - это конечно пздц уже напряжно.
есть такие подфорумы? ( с 12-ю темами всего )
Да. Ты в нем писал вчера.
...
Рейтинг: 0 / 0
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536457
basename
Скрыть профиль Поместить в игнор-лист
Участник
eNose  12.09.2023, 14:31
[игнорируется]
https://resql.ru/forum/forum.php?fid=64

да, дело исключительно в паджинации.

пусть покажет запрос
Вот трассировка, что происходит при открытии подфорума из 12 тем
Код
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
193.
194.
195.
196.
197.
198.
199.
200.
201.
202.
203.
204.
205.
206.
207.
208.
209.
210.
211.
212.
213.
214.
215.
216.
217.
218.
219.
220.
221.
222.
223.
224.
225.
226.
227.
228.
229.
230.
231.
232.
233.
234.
235.
236.
237.
238.
239.
240.
241.
242.
243.
244.
245.
246.
247.
248.
249.
250.
251.
252.
253.
254.
255.
256.
257.
258.
259.
260.
261.
262.
263.
264.
265.
266.
267.
268.
269.
270.
271.
272.
273.
274.
275.
276.
277.
278.
279.
280.
281.
282.
283.
284.
285.
286.
287.
288.
289.
290.
291.
292.
293.
294.
295.
296.
297.
298.
299.
300.
301.
302.
303.
304.
305.
306.
307.
308.
309.
310.
311.
312.
313.
314.
315.
316.
317.
318.
319.
320.
321.
322.
323.
324.
325.
326.
327.
328.
329.
330.
331.
332.
333.
334.
335.
336.
337.
338.
339.
340.
341.
342.
343.
344.
345.
346.
347.
348.
349.
350.
351.
352.
353.
354.
355.
356.
357.
358.
359.
360.
361.
362.
363.
364.
365.
366.
367.
368.
369.
370.
371.
372.
373.
374.
375.
376.
377.
378.
379.
380.
381.
382.
383.
384.
385.
386.
387.
388.
389.
390.
391.
392.
393.
394.
395.
396.
397.
398.
399.
400.
401.
402.
403.
404.
405.
406.
407.
408.
409.
410.
411.
412.
413.
414.
415.
416.
417.
418.
419.
420.
421.
422.
423.
424.
425.
426.
427.
428.
429.
430.
431.
432.
433.
434.
435.
436.
437.
438.
439.
440.
441.
442.
443.
444.
445.
446.
447.
448.
449.
450.
451.
452.
453.
454.
455.
456.
457.
458.
459.
460.
461.
462.
463.
464.
465.
466.
467.
[root@dragon log]# cat trace_sql.log
----------------------------------------------------------------------
Started: /forum/forum.php?fid=64
----------------------------------------------------------------------
select
                             block_tor_ips, moderator_log, default_sender, receiver, whois_server, approval_required, hide_online_status,
                             dislikes_active, rates_active, dislikes_anonym, skin, max_poll_options,
                             max_message_length, max_pinned_topics, max_private_members,
                             max_att_size, max_att_size_audiovideo, max_messages_minute, max_messages_hour, max_messages_day,
                             max_topics_day, min_search_interval, max_rates_hour,
                             max_topic_name_symbols, max_user_name_symbols, hide_users_from_robots,
                             celebration_active, mourning_active, snow_effect, archive_mode
                             from v1_settings

execute_query() [include/_generic/ForumManager.class.php, 4519]
  get_settings() [include/general_inc.php, 208]
    require_once() [forum.php, 5]

Elapsed: 0ms
----------------------------------------------------------------------
select guest_name
              from v1_protected_guests
              order by guest_name

execute_query() [include/_generic/ForumManager.class.php, 4654]
  get_settings() [include/general_inc.php, 208]
    require_once() [forum.php, 5]

Elapsed: 0ms
----------------------------------------------------------------------
select last_activity from v1_read_marker_activity where read_marker = 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU='

execute_query() [include/_generic/ForumManager.class.php, 24912]
  check_read_marker_last_activity() [include/_generic/ForumManager.class.php, 30312]
    read_user_cookies() [include/general_inc.php, 210]
      require_once() [forum.php, 5]

Elapsed: 0ms
----------------------------------------------------------------------
select id, password from v1_forum where protected_by_password = 1

execute_query() [include/_generic/ForumManager.class.php, 30477]
  read_user_cookies() [include/general_inc.php, 210]
    require_once() [forum.php, 5]

Elapsed: 0ms
----------------------------------------------------------------------
select read_marker, author
                  from v1_read_marker_activity
                  where (current_name_start > '2023-09-12 12:50:47' or current_name_hits < 500)
                  and author is not NULL

execute_query() [include/_generic/ForumManager.class.php, 5744]
  update_user_status() [include/general_inc.php, 214]
    require_once() [forum.php, 5]

Elapsed: 35ms
----------------------------------------------------------------------
select block_expires, block_reason
                                 from v1_ip_blocked
                                 where ip = '193.26.135.2' and tp = 'ip'

execute_query() [include/_generic/ForumManager.class.php, 5770]
  update_user_status() [include/general_inc.php, 214]
    require_once() [forum.php, 5]

Elapsed: 1ms
----------------------------------------------------------------------
select v1_forum.id, name, description, v1_forum.creation_date,
                             user_posting_as_guest,
                             topic_count, topic_count_total,
                             last_message_date,
                             v1_forum.deleted, closed,
                             v1_post.user_id, v1_post.author, v1_user.user_name, v1_post.read_marker,
                             last_visit_date, logout
                             from v1_forum
                             inner join v1_forum_statistics on (v1_forum.id = v1_forum_statistics.forum_id)
                             left join v1_post on (v1_forum_statistics.last_message_id = v1_post.id)
                             left join v1_user on (v1_post.user_id = v1_user.id)
                             where v1_forum.name <> 'PRIVATE_MESSAGES' and restricted_access = 0
                             order by sort_order, name

execute_query() [include/_generic/ForumManager.class.php, 2374]
  get_forum_list() [include/general_inc.php, 218]
    require_once() [forum.php, 5]

Elapsed: 2ms
----------------------------------------------------------------------
select user_id, forum_id, user_name,
                             last_visit_date, logout
                             from
                             v1_forum_moderator
                             inner join v1_user on (v1_forum_moderator.user_id = v1_user.id)
                             order by user_name

execute_query() [include/_generic/ForumManager.class.php, 2434]
  get_forum_list() [include/general_inc.php, 218]
    require_once() [forum.php, 5]

Elapsed: 1ms
----------------------------------------------------------------------
select block_level from v1_tor_ips where ip = '193.26.135.2'

execute_query() [include/_generic/ForumManager.class.php, 38703]
  check_tor_ip() [forum.php, 7]

Elapsed: 0ms
----------------------------------------------------------------------
select id from v1_forum where name = 'PRIVATE_MESSAGES'

execute_query() [include/_generic/ForumManager.class.php, 25078]
  get_private_forum_id() [forum.php, 18]

Elapsed: 0ms
----------------------------------------------------------------------
select
                             id, name, description, no_guests, restricted_guest_mode, user_posting_as_guest, stringent_rules, allow_edit, restricted_access, hide_from_robots, sort_order,
                             access_duration, access_message_count, disable_ignore,
                             protected_by_password, deleted, closed, topic_count topic_count
                             from v1_forum
                             inner join v1_forum_statistics on (v1_forum.id = v1_forum_statistics.forum_id)
                             where id = 64

execute_query() [include/_generic/ForumManager.class.php, 3815]
  get_forum_data() [forum.php, 49]

Elapsed: 1ms
----------------------------------------------------------------------
select user_id, forum_id, user_name,
                             last_visit_date, logout
                             from
                             v1_forum_moderator
                             inner join v1_user on (v1_forum_moderator.user_id = v1_user.id)
                             where forum_id = 64
                             order by user_name

execute_query() [include/_generic/ForumManager.class.php, 3925]
  get_forum_data() [forum.php, 49]

Elapsed: 1ms
----------------------------------------------------------------------
select id, password, protected_by_password, v1_forum_moderator.forum_id is_moderator
                             from v1_forum
                             left join v1_forum_moderator on (v1_forum.id = v1_forum_moderator.forum_id and user_id = 0)
                             where v1_forum.id = 64

execute_query() [include/_generic/ForumManager.class.php, 2316]
  need_forum_password() [forum.php, 60]

Elapsed: 0ms
----------------------------------------------------------------------
select name, deleted, protected_by_password, restricted_access from v1_forum where id = 64

execute_query() [include/_generic/ForumManager.class.php, 2154]
  has_access_to_forum() [forum.php, 67]

Elapsed: 0ms
----------------------------------------------------------------------
select block_expires
                           from v1_forum_blocked
                           where user_id = 0 and forum_id = 64

execute_query() [include/_generic/ForumManager.class.php, 2202]
  has_access_to_forum() [forum.php, 67]

Elapsed: 0ms
----------------------------------------------------------------------
select 1 from v1_forum where v1_forum.id = 64 and v1_forum.name <> 'PRIVATE_MESSAGES' and restricted_access = 0

execute_query() [include/_generic/ForumManager.class.php, 2256]
  has_access_to_forum() [forum.php, 67]

Elapsed: 0ms
----------------------------------------------------------------------
BEGIN

execute_query() [include/MySQL/MySQL_DBWorker.class.php, 463]
  start_transaction() [include/_generic/ForumManager.class.php, 27232]
    update_forum_read_status() [forum.php, 99]

Elapsed: 0ms
----------------------------------------------------------------------
update v1_forum_read_markers
                             set last_activity = '2023-09-12 14:50:47', ip = '193.26.135.2'
                             where read_marker = 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU='

execute_query() [include/_generic/ForumManager.class.php, 27241]
  update_forum_read_status() [forum.php, 99]

Elapsed: 1ms
----------------------------------------------------------------------
update v1_read_marker_activity
                             set current_name_hits = 0, current_name_start = '2023-09-12 14:50:47'
                             where read_marker = 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU=' and (author is NULL or author <> NULL)

execute_query() [include/_generic/ForumManager.class.php, 27251]
  update_forum_read_status() [forum.php, 99]

Elapsed: 0ms
----------------------------------------------------------------------
update v1_read_marker_activity
                             set last_activity = '2023-09-12 14:50:47', ip = '193.26.135.2', hits = hits + 1, current_name_hits = current_name_hits + 1,
                             author = author, user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 YaBrowser/23.7.1.1269 (corp) Yowser/2.5 Safari/537.36'
                             where read_marker = 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU='

execute_query() [include/_generic/ForumManager.class.php, 27268]
  update_forum_read_status() [forum.php, 99]

Elapsed: 0ms
----------------------------------------------------------------------
COMMIT

execute_query() [include/MySQL/MySQL_DBWorker.class.php, 469]
  commit_transaction() [include/_generic/ForumManager.class.php, 27343]
    update_forum_read_status() [forum.php, 99]

Elapsed: 2ms
----------------------------------------------------------------------
insert into v1_forum_read_markers
         (forum_id, read_marker, first_read_date, first_activity, last_activity, ip)
          select
         64, 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU=', '2023-09-12 14:50:47', '2023-09-12 14:50:47', '2023-09-12 14:50:47', '193.26.135.2'
         from v1_dual
         where not exists (select 1 from v1_forum_read_markers where forum_id = 64 and read_marker = 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU=')

execute_query() [include/_generic/ForumManager.class.php, 27376]
  update_forum_read_status() [forum.php, 99]

Elapsed: 0ms
----------------------------------------------------------------------
insert into v1_read_marker_activity
         (read_marker, ip, first_activity, last_activity, current_name_start, author, user_agent, hits, current_name_hits)
         select
         'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU=', '193.26.135.2', '2023-09-12 14:50:47', '2023-09-12 14:50:47', '2023-09-12 14:50:47', NULL, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 YaBrowser/23.7.1.1269 (corp) Yowser/2.5 Safari/537.36', 0, 0
         from v1_dual
         where not exists (select 1 from v1_read_marker_activity where read_marker = 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU=')

execute_query() [include/_generic/ForumManager.class.php, 27388]
  update_forum_read_status() [forum.php, 99]

Elapsed: 0ms
----------------------------------------------------------------------
select id from v1_forum where name = 'PRIVATE_MESSAGES'

execute_query() [include/_generic/ForumManager.class.php, 25078]
  get_private_forum_id() [include/_generic/ForumManager.class.php, 34052]
    get_forum_topics() [forum.php, 104]

Elapsed: 0ms
----------------------------------------------------------------------
select v1_topic.id, v1_topic.name, v1_topic.creation_date,
                             v1_topic_statistics.last_message_date,
                             v1_topic_statistics.post_count,
                             v1_topic_statistics.post_count_total,
                             v1_topic_statistics.hits_count,
                             v1_topic_statistics.bot_hits_count,
                             v1_topic.profiled_topic,
                             v1_topic.deleted, v1_topic.closed, v1_topic.pinned, v1_topic.publish_delay, has_pinned_post,
                             v1_forum.deleted forum_deleted,
                             v1_topic.user_id, v1_topic.author, v1_user.user_name, v1_topic.read_marker,
                             v1_user.last_visit_date, v1_user.logout,
                             forum_id, v1_forum.name forum_name, is_poll
                             from v1_topic
                             inner join v1_topic_statistics on (v1_topic.id = v1_topic_statistics.topic_id)
                             inner join v1_forum on (v1_topic.forum_id = v1_forum.id)
                             left join v1_user on (v1_topic.user_id = v1_user.id)
                             where v1_topic.forum_id = 64 and v1_topic.deleted + v1_forum.deleted = 0

                             and (v1_topic.pinned = 1  )
                             order by v1_topic.publish_delay, v1_topic_statistics.last_message_date desc, v1_topic.id desc

execute_query() [include/_generic/ForumManager.class.php, 34274]
  get_forum_topics() [forum.php, 104]

Elapsed: 1ms
----------------------------------------------------------------------

          select
           v1_topic.id, v1_topic.name, v1_topic.creation_date,
           v1_topic_statistics.last_message_date,
           v1_topic_statistics.post_count,
           v1_topic_statistics.post_count_total,
           v1_topic_statistics.hits_count,
           v1_topic_statistics.bot_hits_count,
           v1_topic.profiled_topic,
           v1_topic.deleted, v1_topic.closed, v1_topic.pinned, v1_topic.publish_delay, has_pinned_post,
           v1_forum.deleted forum_deleted,
           v1_topic.user_id, v1_topic.author, v1_topic.read_marker, v1_user.user_name,
               v1_user.last_visit_date, v1_user.logout,
           forum_id, v1_forum.name forum_name, is_poll, v1_topic.no_guests
           from v1_topic
           inner join v1_topic_statistics force index (v1_topic_statistics_lmdate_idx) on (v1_topic.id = v1_topic_statistics.topic_id)
           inner join v1_forum on (v1_topic.forum_id = v1_forum.id)
           left join v1_user on (v1_topic.user_id = v1_user.id)
           where v1_topic.forum_id = 64 and v1_topic.deleted + v1_forum.deleted = 0
 and v1_topic.pinned + v1_topic.publish_delay = 0
           order by v1_topic_statistics.last_message_date desc
           limit 0, 38

execute_query() [include/_generic/ForumManager.class.php, 34359]
  get_forum_topics() [forum.php, 104]

Elapsed: 6027ms
----------------------------------------------------------------------
select v1_topic.id, forum_id,
            v1_post.user_id last_author_id, v1_post.author last_author, v1_post.read_marker last_author_readmarker,
            last_user.last_visit_date last_user_last_visit_date, last_user.logout last_user_logout
            from
            v1_topic
            inner join v1_topic_statistics on (v1_topic.id = v1_topic_statistics.topic_id)
            left join v1_post on (v1_topic_statistics.last_message_id = v1_post.id)
            left join v1_user last_user on (v1_post.user_id = last_user.id)
            where v1_topic.id in (2186819,2186818,2186837,2186822,2186830,2186841,2186823,2186832,2186824,2186833,2186825,2186829)

execute_query() [include/_generic/ForumManager.class.php, 34438]
  get_forum_topics() [forum.php, 104]

Elapsed: 1ms
----------------------------------------------------------------------
select topic_id, participant_id, user_name,
                             v1_user.last_visit_date, v1_user.logout
                             from v1_private_topics
                             inner join v1_user on (v1_private_topics.participant_id = v1_user.id)
                             where topic_id in (2186819,2186818,2186837,2186822,2186830,2186841,2186823,2186832,2186824,2186833,2186825,2186829)
                             order by v1_private_topics.last_visit_date desc

execute_query() [include/_generic/ForumManager.class.php, 34467]
  get_forum_topics() [forum.php, 104]

Elapsed: 0ms
----------------------------------------------------------------------
select topic_id, user_id, user_name,
                             last_visit_date, logout
                             from v1_topic_moderator
                             inner join v1_user on (v1_topic_moderator.user_id = v1_user.id)
                             where topic_id in (2186819,2186818,2186837,2186822,2186830,2186841,2186823,2186832,2186824,2186833,2186825,2186829)
                             order by user_name

execute_query() [include/_generic/ForumManager.class.php, 34493]
  get_forum_topics() [forum.php, 104]

Elapsed: 0ms
----------------------------------------------------------------------
select topic_id
              from
              v1_post
              inner join v1_topic on (v1_post.topic_id = v1_topic.id)
              where v1_post.creation_date >= '2023-09-12 13:50:53'
              group by topic_id
              having count(*) >= 15 and count(distinct v1_post.author) > 2

execute_query() [include/_generic/ForumManager.class.php, 34520]
  get_forum_topics() [forum.php, 104]

Elapsed: 0ms
----------------------------------------------------------------------
select topic_id
              from
              v1_post
              inner join v1_topic on (v1_post.topic_id = v1_topic.id)
              where v1_post.creation_date >= '2023-09-11 14:50:53'
              group by topic_id
              having count(*) >= 100 and count(distinct v1_post.author) > 2

execute_query() [include/_generic/ForumManager.class.php, 34544]
  get_forum_topics() [forum.php, 104]

Elapsed: 1ms
----------------------------------------------------------------------
select id topic_id from v1_topic where id in (-1) and id in (2186819,2186818,2186837,2186822,2186830,2186841,2186823,2186832,2186824,2186833,2186825,2186829)

execute_query() [include/_generic/ForumManager.class.php, 34590]
  get_forum_topics() [forum.php, 104]

Elapsed: 0ms
----------------------------------------------------------------------
select id topic_id from v1_topic where id in (-1) and id in (2186819,2186818,2186837,2186822,2186830,2186841,2186823,2186832,2186824,2186833,2186825,2186829)

execute_query() [include/_generic/ForumManager.class.php, 34615]
  get_forum_topics() [forum.php, 104]

Elapsed: 0ms
----------------------------------------------------------------------
select count(*) cnt, min(creation_date) first_topic_date
                from v1_topic
                where read_marker = 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU=' and creation_date >= '2023-09-11 14:50:53' and publish_delay <> 1 and is_private < 1

execute_query() [include/_generic/ForumManager.class.php, 24859]
  check_topic_limit() [forum.php, 144]

Elapsed: 0ms
----------------------------------------------------------------------
insert into v1_forum_hits (forum_id, topic_id, dt, user_id, hits_count, duration, guest_name, user_agent, uri, ip, read_marker, browser, os, bot)
              values
              (64, NULL, '2023-09-12 14:50:53', NULL, 1, 134, NULL, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 YaBrowser/23.7.1.1269 (corp) Yowser/2.5 Safari/537.36', 'forum.php?fid=64&trace_sql=1', '193.26.135.2', 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU=', 'Yandex Browser', 'Windows 10', NULL)

execute_query() [include/_generic/ForumManager.class.php, 27022]
  track_hit() [forum.php, 146]

Elapsed: 6ms
----------------------------------------------------------------------
update v1_read_marker_activity
                             set current_name_hits = 0, current_name_start = '2023-09-12 14:50:53'
                             where read_marker = 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU=' and (author is NULL or author <> NULL)

execute_query() [include/_generic/ForumManager.class.php, 27031]
  track_hit() [forum.php, 146]

Elapsed: 0ms
----------------------------------------------------------------------
update v1_read_marker_activity
                             set last_activity = '2023-09-12 14:50:53', ip = '193.26.135.2', hits = hits + 1, current_name_hits = current_name_hits + 1,
                             author = author, user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 YaBrowser/23.7.1.1269 (corp) Yowser/2.5 Safari/537.36'
                             where read_marker = 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU='

execute_query() [include/_generic/ForumManager.class.php, 27045]
  track_hit() [forum.php, 146]

Elapsed: 2ms
----------------------------------------------------------------------
insert into v1_daily_statistics (dt, user_id, forum_id)
                  select '2023-09-12', NULL, 64
                  from v1_dual
                  where
                  not exists (select 1 from v1_daily_statistics where dt = '2023-09-12' and user_id is NULL and forum_id = 64);

execute_query() [include/_generic/ForumManager.class.php, 27150]
  track_hit() [forum.php, 146]

Elapsed: 0ms
----------------------------------------------------------------------
update v1_daily_statistics set
                  hits_count = hits_count + 1
                  where
                  dt = '2023-09-12' and user_id is NULL and forum_id = 64;

execute_query() [include/_generic/ForumManager.class.php, 27160]
  track_hit() [forum.php, 146]

Elapsed: 1ms
----------------------------------------------------------------------
select v1_user.id, v1_user.user_name, forum_id, topic_id, guest_name, v1_forum_hits.ip, user_agent, logout,
                             max(dt) last_time
                             from v1_forum_hits
                             left join v1_user on (v1_forum_hits.user_id = v1_user.id)
                             where dt >= '2023-09-12 14:40:53'
                             group by v1_user.id, v1_user.user_name, forum_id, topic_id, guest_name, v1_forum_hits.ip, user_agent, logout
                             order by max(dt) desc

execute_query() [include/_generic/ForumManager.class.php, 7478]
  get_online_users() [forum.php, 152]

Elapsed: 0ms
----------------------------------------------------------------------
select new_dt from v1_cache_invalidation

execute_query() [include/_generic/NewChecker.class.php, 129]
  calculate_new_messages() [include/_generic/ForumManager.class.php, 3624]
    calculate_new_messages() [include/check_new_inc.php, 8]
      require_once() [forum.php, 156]

Elapsed: 0ms
----------------------------------------------------------------------
Total execution time: 6189ms
----------------------------------------------------------------------

[root@dragon log]#
Вот сам запрос, который выполняется 6 секунд в данном случае
Код: SQL
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
          select
           v1_topic.id, v1_topic.name, v1_topic.creation_date,
           v1_topic_statistics.last_message_date,
           v1_topic_statistics.post_count,
           v1_topic_statistics.post_count_total,
           v1_topic_statistics.hits_count,
           v1_topic_statistics.bot_hits_count,
           v1_topic.profiled_topic,
           v1_topic.deleted, v1_topic.closed, v1_topic.pinned, v1_topic.publish_delay, has_pinned_post,
           v1_forum.deleted forum_deleted,
           v1_topic.user_id, v1_topic.author, v1_topic.read_marker, v1_user.user_name,
               v1_user.last_visit_date, v1_user.logout,
           forum_id, v1_forum.name forum_name, is_poll, v1_topic.no_guests
           from v1_topic
           inner join v1_topic_statistics force index (v1_topic_statistics_lmdate_idx) on (v1_topic.id = v1_topic_statistics.topic_id)
           inner join v1_forum on (v1_topic.forum_id = v1_forum.id)
           left join v1_user on (v1_topic.user_id = v1_user.id)
           where v1_topic.forum_id = 64 and v1_topic.deleted + v1_forum.deleted = 0
 and v1_topic.pinned + v1_topic.publish_delay = 0
           order by v1_topic_statistics.last_message_date desc
           limit 0, 38
Если убрать хинт
Код: SQL
1.
 force index (v1_topic_statistics_lmdate_idx)
то работает быстро на этом форуме, но на больших уже долго.
...
Рейтинг: 0 / 0
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536475
basename
Скрыть профиль Поместить в игнор-лист
Участник
basename  12.09.2023, 15:07
[игнорируется]
eNose  12.09.2023, 14:31
[игнорируется]
https://resql.ru/forum/forum.php?fid=64

да, дело исключительно в паджинации.

пусть покажет запрос
Вот трассировка, что происходит при открытии подфорума из 12 тем
Код
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
193.
194.
195.
196.
197.
198.
199.
200.
201.
202.
203.
204.
205.
206.
207.
208.
209.
210.
211.
212.
213.
214.
215.
216.
217.
218.
219.
220.
221.
222.
223.
224.
225.
226.
227.
228.
229.
230.
231.
232.
233.
234.
235.
236.
237.
238.
239.
240.
241.
242.
243.
244.
245.
246.
247.
248.
249.
250.
251.
252.
253.
254.
255.
256.
257.
258.
259.
260.
261.
262.
263.
264.
265.
266.
267.
268.
269.
270.
271.
272.
273.
274.
275.
276.
277.
278.
279.
280.
281.
282.
283.
284.
285.
286.
287.
288.
289.
290.
291.
292.
293.
294.
295.
296.
297.
298.
299.
300.
301.
302.
303.
304.
305.
306.
307.
308.
309.
310.
311.
312.
313.
314.
315.
316.
317.
318.
319.
320.
321.
322.
323.
324.
325.
326.
327.
328.
329.
330.
331.
332.
333.
334.
335.
336.
337.
338.
339.
340.
341.
342.
343.
344.
345.
346.
347.
348.
349.
350.
351.
352.
353.
354.
355.
356.
357.
358.
359.
360.
361.
362.
363.
364.
365.
366.
367.
368.
369.
370.
371.
372.
373.
374.
375.
376.
377.
378.
379.
380.
381.
382.
383.
384.
385.
386.
387.
388.
389.
390.
391.
392.
393.
394.
395.
396.
397.
398.
399.
400.
401.
402.
403.
404.
405.
406.
407.
408.
409.
410.
411.
412.
413.
414.
415.
416.
417.
418.
419.
420.
421.
422.
423.
424.
425.
426.
427.
428.
429.
430.
431.
432.
433.
434.
435.
436.
437.
438.
439.
440.
441.
442.
443.
444.
445.
446.
447.
448.
449.
450.
451.
452.
453.
454.
455.
456.
457.
458.
459.
460.
461.
462.
463.
464.
465.
466.
467.
[root@dragon log]# cat trace_sql.log
----------------------------------------------------------------------
Started: /forum/forum.php?fid=64
----------------------------------------------------------------------
select
                             block_tor_ips, moderator_log, default_sender, receiver, whois_server, approval_required, hide_online_status,
                             dislikes_active, rates_active, dislikes_anonym, skin, max_poll_options,
                             max_message_length, max_pinned_topics, max_private_members,
                             max_att_size, max_att_size_audiovideo, max_messages_minute, max_messages_hour, max_messages_day,
                             max_topics_day, min_search_interval, max_rates_hour,
                             max_topic_name_symbols, max_user_name_symbols, hide_users_from_robots,
                             celebration_active, mourning_active, snow_effect, archive_mode
                             from v1_settings

execute_query() [include/_generic/ForumManager.class.php, 4519]
  get_settings() [include/general_inc.php, 208]
    require_once() [forum.php, 5]

Elapsed: 0ms
----------------------------------------------------------------------
select guest_name
              from v1_protected_guests
              order by guest_name

execute_query() [include/_generic/ForumManager.class.php, 4654]
  get_settings() [include/general_inc.php, 208]
    require_once() [forum.php, 5]

Elapsed: 0ms
----------------------------------------------------------------------
select last_activity from v1_read_marker_activity where read_marker = 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU='

execute_query() [include/_generic/ForumManager.class.php, 24912]
  check_read_marker_last_activity() [include/_generic/ForumManager.class.php, 30312]
    read_user_cookies() [include/general_inc.php, 210]
      require_once() [forum.php, 5]

Elapsed: 0ms
----------------------------------------------------------------------
select id, password from v1_forum where protected_by_password = 1

execute_query() [include/_generic/ForumManager.class.php, 30477]
  read_user_cookies() [include/general_inc.php, 210]
    require_once() [forum.php, 5]

Elapsed: 0ms
----------------------------------------------------------------------
select read_marker, author
                  from v1_read_marker_activity
                  where (current_name_start > '2023-09-12 12:50:47' or current_name_hits < 500)
                  and author is not NULL

execute_query() [include/_generic/ForumManager.class.php, 5744]
  update_user_status() [include/general_inc.php, 214]
    require_once() [forum.php, 5]

Elapsed: 35ms
----------------------------------------------------------------------
select block_expires, block_reason
                                 from v1_ip_blocked
                                 where ip = '193.26.135.2' and tp = 'ip'

execute_query() [include/_generic/ForumManager.class.php, 5770]
  update_user_status() [include/general_inc.php, 214]
    require_once() [forum.php, 5]

Elapsed: 1ms
----------------------------------------------------------------------
select v1_forum.id, name, description, v1_forum.creation_date,
                             user_posting_as_guest,
                             topic_count, topic_count_total,
                             last_message_date,
                             v1_forum.deleted, closed,
                             v1_post.user_id, v1_post.author, v1_user.user_name, v1_post.read_marker,
                             last_visit_date, logout
                             from v1_forum
                             inner join v1_forum_statistics on (v1_forum.id = v1_forum_statistics.forum_id)
                             left join v1_post on (v1_forum_statistics.last_message_id = v1_post.id)
                             left join v1_user on (v1_post.user_id = v1_user.id)
                             where v1_forum.name <> 'PRIVATE_MESSAGES' and restricted_access = 0
                             order by sort_order, name

execute_query() [include/_generic/ForumManager.class.php, 2374]
  get_forum_list() [include/general_inc.php, 218]
    require_once() [forum.php, 5]

Elapsed: 2ms
----------------------------------------------------------------------
select user_id, forum_id, user_name,
                             last_visit_date, logout
                             from
                             v1_forum_moderator
                             inner join v1_user on (v1_forum_moderator.user_id = v1_user.id)
                             order by user_name

execute_query() [include/_generic/ForumManager.class.php, 2434]
  get_forum_list() [include/general_inc.php, 218]
    require_once() [forum.php, 5]

Elapsed: 1ms
----------------------------------------------------------------------
select block_level from v1_tor_ips where ip = '193.26.135.2'

execute_query() [include/_generic/ForumManager.class.php, 38703]
  check_tor_ip() [forum.php, 7]

Elapsed: 0ms
----------------------------------------------------------------------
select id from v1_forum where name = 'PRIVATE_MESSAGES'

execute_query() [include/_generic/ForumManager.class.php, 25078]
  get_private_forum_id() [forum.php, 18]

Elapsed: 0ms
----------------------------------------------------------------------
select
                             id, name, description, no_guests, restricted_guest_mode, user_posting_as_guest, stringent_rules, allow_edit, restricted_access, hide_from_robots, sort_order,
                             access_duration, access_message_count, disable_ignore,
                             protected_by_password, deleted, closed, topic_count topic_count
                             from v1_forum
                             inner join v1_forum_statistics on (v1_forum.id = v1_forum_statistics.forum_id)
                             where id = 64

execute_query() [include/_generic/ForumManager.class.php, 3815]
  get_forum_data() [forum.php, 49]

Elapsed: 1ms
----------------------------------------------------------------------
select user_id, forum_id, user_name,
                             last_visit_date, logout
                             from
                             v1_forum_moderator
                             inner join v1_user on (v1_forum_moderator.user_id = v1_user.id)
                             where forum_id = 64
                             order by user_name

execute_query() [include/_generic/ForumManager.class.php, 3925]
  get_forum_data() [forum.php, 49]

Elapsed: 1ms
----------------------------------------------------------------------
select id, password, protected_by_password, v1_forum_moderator.forum_id is_moderator
                             from v1_forum
                             left join v1_forum_moderator on (v1_forum.id = v1_forum_moderator.forum_id and user_id = 0)
                             where v1_forum.id = 64

execute_query() [include/_generic/ForumManager.class.php, 2316]
  need_forum_password() [forum.php, 60]

Elapsed: 0ms
----------------------------------------------------------------------
select name, deleted, protected_by_password, restricted_access from v1_forum where id = 64

execute_query() [include/_generic/ForumManager.class.php, 2154]
  has_access_to_forum() [forum.php, 67]

Elapsed: 0ms
----------------------------------------------------------------------
select block_expires
                           from v1_forum_blocked
                           where user_id = 0 and forum_id = 64

execute_query() [include/_generic/ForumManager.class.php, 2202]
  has_access_to_forum() [forum.php, 67]

Elapsed: 0ms
----------------------------------------------------------------------
select 1 from v1_forum where v1_forum.id = 64 and v1_forum.name <> 'PRIVATE_MESSAGES' and restricted_access = 0

execute_query() [include/_generic/ForumManager.class.php, 2256]
  has_access_to_forum() [forum.php, 67]

Elapsed: 0ms
----------------------------------------------------------------------
BEGIN

execute_query() [include/MySQL/MySQL_DBWorker.class.php, 463]
  start_transaction() [include/_generic/ForumManager.class.php, 27232]
    update_forum_read_status() [forum.php, 99]

Elapsed: 0ms
----------------------------------------------------------------------
update v1_forum_read_markers
                             set last_activity = '2023-09-12 14:50:47', ip = '193.26.135.2'
                             where read_marker = 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU='

execute_query() [include/_generic/ForumManager.class.php, 27241]
  update_forum_read_status() [forum.php, 99]

Elapsed: 1ms
----------------------------------------------------------------------
update v1_read_marker_activity
                             set current_name_hits = 0, current_name_start = '2023-09-12 14:50:47'
                             where read_marker = 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU=' and (author is NULL or author <> NULL)

execute_query() [include/_generic/ForumManager.class.php, 27251]
  update_forum_read_status() [forum.php, 99]

Elapsed: 0ms
----------------------------------------------------------------------
update v1_read_marker_activity
                             set last_activity = '2023-09-12 14:50:47', ip = '193.26.135.2', hits = hits + 1, current_name_hits = current_name_hits + 1,
                             author = author, user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 YaBrowser/23.7.1.1269 (corp) Yowser/2.5 Safari/537.36'
                             where read_marker = 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU='

execute_query() [include/_generic/ForumManager.class.php, 27268]
  update_forum_read_status() [forum.php, 99]

Elapsed: 0ms
----------------------------------------------------------------------
COMMIT

execute_query() [include/MySQL/MySQL_DBWorker.class.php, 469]
  commit_transaction() [include/_generic/ForumManager.class.php, 27343]
    update_forum_read_status() [forum.php, 99]

Elapsed: 2ms
----------------------------------------------------------------------
insert into v1_forum_read_markers
         (forum_id, read_marker, first_read_date, first_activity, last_activity, ip)
          select
         64, 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU=', '2023-09-12 14:50:47', '2023-09-12 14:50:47', '2023-09-12 14:50:47', '193.26.135.2'
         from v1_dual
         where not exists (select 1 from v1_forum_read_markers where forum_id = 64 and read_marker = 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU=')

execute_query() [include/_generic/ForumManager.class.php, 27376]
  update_forum_read_status() [forum.php, 99]

Elapsed: 0ms
----------------------------------------------------------------------
insert into v1_read_marker_activity
         (read_marker, ip, first_activity, last_activity, current_name_start, author, user_agent, hits, current_name_hits)
         select
         'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU=', '193.26.135.2', '2023-09-12 14:50:47', '2023-09-12 14:50:47', '2023-09-12 14:50:47', NULL, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 YaBrowser/23.7.1.1269 (corp) Yowser/2.5 Safari/537.36', 0, 0
         from v1_dual
         where not exists (select 1 from v1_read_marker_activity where read_marker = 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU=')

execute_query() [include/_generic/ForumManager.class.php, 27388]
  update_forum_read_status() [forum.php, 99]

Elapsed: 0ms
----------------------------------------------------------------------
select id from v1_forum where name = 'PRIVATE_MESSAGES'

execute_query() [include/_generic/ForumManager.class.php, 25078]
  get_private_forum_id() [include/_generic/ForumManager.class.php, 34052]
    get_forum_topics() [forum.php, 104]

Elapsed: 0ms
----------------------------------------------------------------------
select v1_topic.id, v1_topic.name, v1_topic.creation_date,
                             v1_topic_statistics.last_message_date,
                             v1_topic_statistics.post_count,
                             v1_topic_statistics.post_count_total,
                             v1_topic_statistics.hits_count,
                             v1_topic_statistics.bot_hits_count,
                             v1_topic.profiled_topic,
                             v1_topic.deleted, v1_topic.closed, v1_topic.pinned, v1_topic.publish_delay, has_pinned_post,
                             v1_forum.deleted forum_deleted,
                             v1_topic.user_id, v1_topic.author, v1_user.user_name, v1_topic.read_marker,
                             v1_user.last_visit_date, v1_user.logout,
                             forum_id, v1_forum.name forum_name, is_poll
                             from v1_topic
                             inner join v1_topic_statistics on (v1_topic.id = v1_topic_statistics.topic_id)
                             inner join v1_forum on (v1_topic.forum_id = v1_forum.id)
                             left join v1_user on (v1_topic.user_id = v1_user.id)
                             where v1_topic.forum_id = 64 and v1_topic.deleted + v1_forum.deleted = 0

                             and (v1_topic.pinned = 1  )
                             order by v1_topic.publish_delay, v1_topic_statistics.last_message_date desc, v1_topic.id desc

execute_query() [include/_generic/ForumManager.class.php, 34274]
  get_forum_topics() [forum.php, 104]

Elapsed: 1ms
----------------------------------------------------------------------

          select
           v1_topic.id, v1_topic.name, v1_topic.creation_date,
           v1_topic_statistics.last_message_date,
           v1_topic_statistics.post_count,
           v1_topic_statistics.post_count_total,
           v1_topic_statistics.hits_count,
           v1_topic_statistics.bot_hits_count,
           v1_topic.profiled_topic,
           v1_topic.deleted, v1_topic.closed, v1_topic.pinned, v1_topic.publish_delay, has_pinned_post,
           v1_forum.deleted forum_deleted,
           v1_topic.user_id, v1_topic.author, v1_topic.read_marker, v1_user.user_name,
               v1_user.last_visit_date, v1_user.logout,
           forum_id, v1_forum.name forum_name, is_poll, v1_topic.no_guests
           from v1_topic
           inner join v1_topic_statistics force index (v1_topic_statistics_lmdate_idx) on (v1_topic.id = v1_topic_statistics.topic_id)
           inner join v1_forum on (v1_topic.forum_id = v1_forum.id)
           left join v1_user on (v1_topic.user_id = v1_user.id)
           where v1_topic.forum_id = 64 and v1_topic.deleted + v1_forum.deleted = 0
 and v1_topic.pinned + v1_topic.publish_delay = 0
           order by v1_topic_statistics.last_message_date desc
           limit 0, 38

execute_query() [include/_generic/ForumManager.class.php, 34359]
  get_forum_topics() [forum.php, 104]

Elapsed: 6027ms
----------------------------------------------------------------------
select v1_topic.id, forum_id,
            v1_post.user_id last_author_id, v1_post.author last_author, v1_post.read_marker last_author_readmarker,
            last_user.last_visit_date last_user_last_visit_date, last_user.logout last_user_logout
            from
            v1_topic
            inner join v1_topic_statistics on (v1_topic.id = v1_topic_statistics.topic_id)
            left join v1_post on (v1_topic_statistics.last_message_id = v1_post.id)
            left join v1_user last_user on (v1_post.user_id = last_user.id)
            where v1_topic.id in (2186819,2186818,2186837,2186822,2186830,2186841,2186823,2186832,2186824,2186833,2186825,2186829)

execute_query() [include/_generic/ForumManager.class.php, 34438]
  get_forum_topics() [forum.php, 104]

Elapsed: 1ms
----------------------------------------------------------------------
select topic_id, participant_id, user_name,
                             v1_user.last_visit_date, v1_user.logout
                             from v1_private_topics
                             inner join v1_user on (v1_private_topics.participant_id = v1_user.id)
                             where topic_id in (2186819,2186818,2186837,2186822,2186830,2186841,2186823,2186832,2186824,2186833,2186825,2186829)
                             order by v1_private_topics.last_visit_date desc

execute_query() [include/_generic/ForumManager.class.php, 34467]
  get_forum_topics() [forum.php, 104]

Elapsed: 0ms
----------------------------------------------------------------------
select topic_id, user_id, user_name,
                             last_visit_date, logout
                             from v1_topic_moderator
                             inner join v1_user on (v1_topic_moderator.user_id = v1_user.id)
                             where topic_id in (2186819,2186818,2186837,2186822,2186830,2186841,2186823,2186832,2186824,2186833,2186825,2186829)
                             order by user_name

execute_query() [include/_generic/ForumManager.class.php, 34493]
  get_forum_topics() [forum.php, 104]

Elapsed: 0ms
----------------------------------------------------------------------
select topic_id
              from
              v1_post
              inner join v1_topic on (v1_post.topic_id = v1_topic.id)
              where v1_post.creation_date >= '2023-09-12 13:50:53'
              group by topic_id
              having count(*) >= 15 and count(distinct v1_post.author) > 2

execute_query() [include/_generic/ForumManager.class.php, 34520]
  get_forum_topics() [forum.php, 104]

Elapsed: 0ms
----------------------------------------------------------------------
select topic_id
              from
              v1_post
              inner join v1_topic on (v1_post.topic_id = v1_topic.id)
              where v1_post.creation_date >= '2023-09-11 14:50:53'
              group by topic_id
              having count(*) >= 100 and count(distinct v1_post.author) > 2

execute_query() [include/_generic/ForumManager.class.php, 34544]
  get_forum_topics() [forum.php, 104]

Elapsed: 1ms
----------------------------------------------------------------------
select id topic_id from v1_topic where id in (-1) and id in (2186819,2186818,2186837,2186822,2186830,2186841,2186823,2186832,2186824,2186833,2186825,2186829)

execute_query() [include/_generic/ForumManager.class.php, 34590]
  get_forum_topics() [forum.php, 104]

Elapsed: 0ms
----------------------------------------------------------------------
select id topic_id from v1_topic where id in (-1) and id in (2186819,2186818,2186837,2186822,2186830,2186841,2186823,2186832,2186824,2186833,2186825,2186829)

execute_query() [include/_generic/ForumManager.class.php, 34615]
  get_forum_topics() [forum.php, 104]

Elapsed: 0ms
----------------------------------------------------------------------
select count(*) cnt, min(creation_date) first_topic_date
                from v1_topic
                where read_marker = 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU=' and creation_date >= '2023-09-11 14:50:53' and publish_delay <> 1 and is_private < 1

execute_query() [include/_generic/ForumManager.class.php, 24859]
  check_topic_limit() [forum.php, 144]

Elapsed: 0ms
----------------------------------------------------------------------
insert into v1_forum_hits (forum_id, topic_id, dt, user_id, hits_count, duration, guest_name, user_agent, uri, ip, read_marker, browser, os, bot)
              values
              (64, NULL, '2023-09-12 14:50:53', NULL, 1, 134, NULL, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 YaBrowser/23.7.1.1269 (corp) Yowser/2.5 Safari/537.36', 'forum.php?fid=64&trace_sql=1', '193.26.135.2', 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU=', 'Yandex Browser', 'Windows 10', NULL)

execute_query() [include/_generic/ForumManager.class.php, 27022]
  track_hit() [forum.php, 146]

Elapsed: 6ms
----------------------------------------------------------------------
update v1_read_marker_activity
                             set current_name_hits = 0, current_name_start = '2023-09-12 14:50:53'
                             where read_marker = 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU=' and (author is NULL or author <> NULL)

execute_query() [include/_generic/ForumManager.class.php, 27031]
  track_hit() [forum.php, 146]

Elapsed: 0ms
----------------------------------------------------------------------
update v1_read_marker_activity
                             set last_activity = '2023-09-12 14:50:53', ip = '193.26.135.2', hits = hits + 1, current_name_hits = current_name_hits + 1,
                             author = author, user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 YaBrowser/23.7.1.1269 (corp) Yowser/2.5 Safari/537.36'
                             where read_marker = 'OTU0ZWI1234jYTg2NGM2NGVlMWU2NjlkZmFiMDFjOTU='

execute_query() [include/_generic/ForumManager.class.php, 27045]
  track_hit() [forum.php, 146]

Elapsed: 2ms
----------------------------------------------------------------------
insert into v1_daily_statistics (dt, user_id, forum_id)
                  select '2023-09-12', NULL, 64
                  from v1_dual
                  where
                  not exists (select 1 from v1_daily_statistics where dt = '2023-09-12' and user_id is NULL and forum_id = 64);

execute_query() [include/_generic/ForumManager.class.php, 27150]
  track_hit() [forum.php, 146]

Elapsed: 0ms
----------------------------------------------------------------------
update v1_daily_statistics set
                  hits_count = hits_count + 1
                  where
                  dt = '2023-09-12' and user_id is NULL and forum_id = 64;

execute_query() [include/_generic/ForumManager.class.php, 27160]
  track_hit() [forum.php, 146]

Elapsed: 1ms
----------------------------------------------------------------------
select v1_user.id, v1_user.user_name, forum_id, topic_id, guest_name, v1_forum_hits.ip, user_agent, logout,
                             max(dt) last_time
                             from v1_forum_hits
                             left join v1_user on (v1_forum_hits.user_id = v1_user.id)
                             where dt >= '2023-09-12 14:40:53'
                             group by v1_user.id, v1_user.user_name, forum_id, topic_id, guest_name, v1_forum_hits.ip, user_agent, logout
                             order by max(dt) desc

execute_query() [include/_generic/ForumManager.class.php, 7478]
  get_online_users() [forum.php, 152]

Elapsed: 0ms
----------------------------------------------------------------------
select new_dt from v1_cache_invalidation

execute_query() [include/_generic/NewChecker.class.php, 129]
  calculate_new_messages() [include/_generic/ForumManager.class.php, 3624]
    calculate_new_messages() [include/check_new_inc.php, 8]
      require_once() [forum.php, 156]

Elapsed: 0ms
----------------------------------------------------------------------
Total execution time: 6189ms
----------------------------------------------------------------------

[root@dragon log]#
Вот сам запрос, который выполняется 6 секунд в данном случае
Код: SQL
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
          select
           v1_topic.id, v1_topic.name, v1_topic.creation_date,
           v1_topic_statistics.last_message_date,
           v1_topic_statistics.post_count,
           v1_topic_statistics.post_count_total,
           v1_topic_statistics.hits_count,
           v1_topic_statistics.bot_hits_count,
           v1_topic.profiled_topic,
           v1_topic.deleted, v1_topic.closed, v1_topic.pinned, v1_topic.publish_delay, has_pinned_post,
           v1_forum.deleted forum_deleted,
           v1_topic.user_id, v1_topic.author, v1_topic.read_marker, v1_user.user_name,
               v1_user.last_visit_date, v1_user.logout,
           forum_id, v1_forum.name forum_name, is_poll, v1_topic.no_guests
           from v1_topic
           inner join v1_topic_statistics force index (v1_topic_statistics_lmdate_idx) on (v1_topic.id = v1_topic_statistics.topic_id)
           inner join v1_forum on (v1_topic.forum_id = v1_forum.id)
           left join v1_user on (v1_topic.user_id = v1_user.id)
           where v1_topic.forum_id = 64 and v1_topic.deleted + v1_forum.deleted = 0
 and v1_topic.pinned + v1_topic.publish_delay = 0
           order by v1_topic_statistics.last_message_date desc
           limit 0, 38
Если убрать хинт
Код: SQL
1.
 force index (v1_topic_statistics_lmdate_idx)
то работает быстро на этом форуме, но на больших уже долго.
Хм, с limit 0 10 отрабатывает мгновенно
...
Рейтинг: 0 / 0
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536499
basename
Скрыть профиль Поместить в игнор-лист
Участник
eNose  12.09.2023, 15:32
[игнорируется]
пусть деда на "хорошем запросе" посмотрит план и хинтами выставит принудительно использование нужных индексов
Планы
Код
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
193.
194.
##### 38

mysql> explain analyze select
    ->            v1_topic.id, v1_topic.name, v1_topic.creation_date,
    ->            v1_topic_statistics.last_message_date,
    ->            v1_topic_statistics.post_count,
    ->            v1_topic_statistics.post_count_total,
    ->            v1_topic_statistics.hits_count,
    ->            v1_topic_statistics.bot_hits_count,
    ->            v1_topic.profiled_topic,
    ->            v1_topic.deleted, v1_topic.closed, v1_topic.pinned, v1_topic.publish_delay, has_pinned_post,
    ->            v1_forum.deleted forum_deleted,
    ->            v1_topic.user_id, v1_topic.author, v1_topic.read_marker, v1_user.user_name,
    ->                v1_user.last_visit_date, v1_user.logout,
    ->            forum_id, v1_forum.name forum_name, is_poll, v1_topic.no_guests
    ->            from v1_topic
    ->            inner join v1_topic_statistics force index (v1_topic_statistics_lmdate_idx) on (v1_topic.id = v1_topic_statistics.topic_id)
    ->            inner join v1_forum on (v1_topic.forum_id = v1_forum.id)
    ->            left join v1_user on (v1_topic.user_id = v1_user.id)
    ->            where v1_topic.forum_id = 64 and v1_topic.deleted + v1_forum.deleted = 0
    ->  and v1_topic.pinned + v1_topic.publish_delay = 0
    ->            order by v1_topic_statistics.last_message_date desc
    ->            limit 0, 38;
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| EXPLAIN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| -> Limit: 38 row(s)  (cost=325532 rows=38) (actual time=0.319..5686 rows=10 loops=1)
    -> Nested loop left join  (cost=325532 rows=38) (actual time=0.314..5686 rows=10 loops=1)
        -> Nested loop inner join  (cost=309927 rows=38) (actual time=0.304..5686 rows=10 loops=1)
            -> Index scan on v1_topic_statistics using V1_TOPIC_STATISTICS_LMDATE_IDX (reverse)  (cost=190 rows=759) (actual time=0.285..2188 rows=1.24e+6 loops=1)
            -> Filter: ((v1_topic.FORUM_ID = 64) and ((v1_topic.DELETED + '0') = 0) and ((v1_topic.PINNED + v1_topic.PUBLISH_DELAY) = 0))  (cost=0.25 rows=0.05) (actual time=0.0027..0.0027 rows=8.05e-6 loops=1.24e+6)
                -> Single-row index lookup on v1_topic using PRIMARY (ID=v1_topic_statistics.TOPIC_ID)  (cost=0.25 rows=1) (actual time=0.00242..0.00245 rows=1 loops=1.24e+6)
        -> Single-row index lookup on v1_user using PRIMARY (ID=v1_topic.USER_ID)  (cost=0.252 rows=1) (actual time=0.00198..0.00201 rows=1 loops=10)
 |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (5.68 sec)

mysql>

##### 20

mysql> explain analyze select
    ->            v1_topic.id, v1_topic.name, v1_topic.creation_date,
    ->            v1_topic_statistics.last_message_date,
    ->            v1_topic_statistics.post_count,
    ->            v1_topic_statistics.post_count_total,
    ->            v1_topic_statistics.hits_count,
    ->            v1_topic_statistics.bot_hits_count,
    ->            v1_topic.profiled_topic,
    ->            v1_topic.deleted, v1_topic.closed, v1_topic.pinned, v1_topic.publish_delay, has_pinned_post,
    ->            v1_forum.deleted forum_deleted,
    ->            v1_topic.user_id, v1_topic.author, v1_topic.read_marker, v1_user.user_name,
    ->                v1_user.last_visit_date, v1_user.logout,
    ->            forum_id, v1_forum.name forum_name, is_poll, v1_topic.no_guests
    ->            from v1_topic
    ->            inner join v1_topic_statistics force index (v1_topic_statistics_lmdate_idx) on (v1_topic.id = v1_topic_statistics.topic_id)
    ->            inner join v1_forum on (v1_topic.forum_id = v1_forum.id)
    ->            left join v1_user on (v1_topic.user_id = v1_user.id)
    ->            where v1_topic.forum_id = 64 and v1_topic.deleted + v1_forum.deleted = 0
    ->  and v1_topic.pinned + v1_topic.publish_delay = 0
    ->            order by v1_topic_statistics.last_message_date desc
    ->            limit 0, 20;
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| EXPLAIN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| -> Limit: 20 row(s)  (cost=325405 rows=20) (actual time=0.334..6079 rows=10 loops=1)
    -> Nested loop left join  (cost=325405 rows=20) (actual time=0.332..6079 rows=10 loops=1)
        -> Nested loop inner join  (cost=309801 rows=20) (actual time=0.322..6079 rows=10 loops=1)
            -> Index scan on v1_topic_statistics using V1_TOPIC_STATISTICS_LMDATE_IDX (reverse)  (cost=99.8 rows=399) (actual time=0.303..2341 rows=1.24e+6 loops=1)
            -> Filter: ((v1_topic.FORUM_ID = 64) and ((v1_topic.DELETED + '0') = 0) and ((v1_topic.PINNED + v1_topic.PUBLISH_DELAY) = 0))  (cost=0.25 rows=0.05) (actual time=0.00289..0.00289 rows=8.05e-6 loops=1.24e+6)
                -> Single-row index lookup on v1_topic using PRIMARY (ID=v1_topic_statistics.TOPIC_ID)  (cost=0.25 rows=1) (actual time=0.00259..0.00262 rows=1 loops=1.24e+6)
        -> Single-row index lookup on v1_user using PRIMARY (ID=v1_topic.USER_ID)  (cost=0.252 rows=1) (actual time=0.00201..0.00204 rows=1 loops=10)
 |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (6.09 sec)

mysql>

##### 11

mysql> explain analyze select
    ->            v1_topic.id, v1_topic.name, v1_topic.creation_date,
    ->            v1_topic_statistics.last_message_date,
    ->            v1_topic_statistics.post_count,
    ->            v1_topic_statistics.post_count_total,
    ->            v1_topic_statistics.hits_count,
    ->            v1_topic_statistics.bot_hits_count,
    ->            v1_topic.profiled_topic,
    ->            v1_topic.deleted, v1_topic.closed, v1_topic.pinned, v1_topic.publish_delay, has_pinned_post,
    ->            v1_forum.deleted forum_deleted,
    ->            v1_topic.user_id, v1_topic.author, v1_topic.read_marker, v1_user.user_name,
    ->                v1_user.last_visit_date, v1_user.logout,
    ->            forum_id, v1_forum.name forum_name, is_poll, v1_topic.no_guests
    ->            from v1_topic
    ->            inner join v1_topic_statistics force index (v1_topic_statistics_lmdate_idx) on (v1_topic.id = v1_topic_statistics.topic_id)
    ->            inner join v1_forum on (v1_topic.forum_id = v1_forum.id)
    ->            left join v1_user on (v1_topic.user_id = v1_user.id)
    ->            where v1_topic.forum_id = 64 and v1_topic.deleted + v1_forum.deleted = 0
    ->  and v1_topic.pinned + v1_topic.publish_delay = 0
    ->            order by v1_topic_statistics.last_message_date desc
    ->            limit 0, 11;
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| EXPLAIN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| -> Limit: 11 row(s)  (cost=325341 rows=11) (actual time=0.693..5673 rows=10 loops=1)
    -> Nested loop left join  (cost=325341 rows=11) (actual time=0.691..5673 rows=10 loops=1)
        -> Nested loop inner join  (cost=309738 rows=11) (actual time=0.669..5673 rows=10 loops=1)
            -> Index scan on v1_topic_statistics using V1_TOPIC_STATISTICS_LMDATE_IDX (reverse)  (cost=54.8 rows=219) (actual time=0.61..2195 rows=1.24e+6 loops=1)
            -> Filter: ((v1_topic.FORUM_ID = 64) and ((v1_topic.DELETED + '0') = 0) and ((v1_topic.PINNED + v1_topic.PUBLISH_DELAY) = 0))  (cost=0.25 rows=0.05) (actual time=0.00269..0.00269 rows=8.05e-6 loops=1.24e+6)
                -> Single-row index lookup on v1_topic using PRIMARY (ID=v1_topic_statistics.TOPIC_ID)  (cost=0.25 rows=1) (actual time=0.00241..0.00244 rows=1 loops=1.24e+6)
        -> Single-row index lookup on v1_user using PRIMARY (ID=v1_topic.USER_ID)  (cost=0.252 rows=1) (actual time=0.00331..0.00334 rows=1 loops=10)
 |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (5.68 sec)

mysql>

##### 10

mysql> explain analyze select
    ->            v1_topic.id, v1_topic.name, v1_topic.creation_date,
    ->            v1_topic_statistics.last_message_date,
    ->            v1_topic_statistics.post_count,
    ->            v1_topic_statistics.post_count_total,
    ->            v1_topic_statistics.hits_count,
    ->            v1_topic_statistics.bot_hits_count,
    ->            v1_topic.profiled_topic,
    ->            v1_topic.deleted, v1_topic.closed, v1_topic.pinned, v1_topic.publish_delay, has_pinned_post,
    ->            v1_forum.deleted forum_deleted,
    ->            v1_topic.user_id, v1_topic.author, v1_topic.read_marker, v1_user.user_name,
    ->                v1_user.last_visit_date, v1_user.logout,
    ->            forum_id, v1_forum.name forum_name, is_poll, v1_topic.no_guests
    ->            from v1_topic
    ->            inner join v1_topic_statistics force index (v1_topic_statistics_lmdate_idx) on (v1_topic.id = v1_topic_statistics.topic_id)
    ->            inner join v1_forum on (v1_topic.forum_id = v1_forum.id)
    ->            left join v1_user on (v1_topic.user_id = v1_user.id)
    ->            where v1_topic.forum_id = 64 and v1_topic.deleted + v1_forum.deleted = 0
    ->  and v1_topic.pinned + v1_topic.publish_delay = 0
    ->            order by v1_topic_statistics.last_message_date desc
    ->            limit 0, 10;
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| EXPLAIN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| -> Limit: 10 row(s)  (cost=325334 rows=9.95) (actual time=0.315..0.421 rows=10 loops=1)
    -> Nested loop left join  (cost=325334 rows=9.95) (actual time=0.29..0.395 rows=10 loops=1)
        -> Nested loop inner join  (cost=309731 rows=9.95) (actual time=0.281..0.371 rows=10 loops=1)
            -> Index scan on v1_topic_statistics using V1_TOPIC_STATISTICS_LMDATE_IDX (reverse)  (cost=49.8 rows=199) (actual time=0.264..0.268 rows=24 loops=1)
            -> Filter: ((v1_topic.FORUM_ID = 64) and ((v1_topic.DELETED + '0') = 0) and ((v1_topic.PINNED + v1_topic.PUBLISH_DELAY) = 0))  (cost=0.25 rows=0.05) (actual time=0.004..0.00405 rows=0.417 loops=24)
                -> Single-row index lookup on v1_topic using PRIMARY (ID=v1_topic_statistics.TOPIC_ID)  (cost=0.25 rows=1) (actual time=0.00359..0.00362 rows=1 loops=24)
        -> Single-row index lookup on v1_user using PRIMARY (ID=v1_topic.USER_ID)  (cost=0.252 rows=1) (actual time=0.00209..0.00213 rows=1 loops=10)
 |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

mysql>

##### 5

mysql> explain analyze select
    ->            v1_topic.id, v1_topic.name, v1_topic.creation_date,
    ->            v1_topic_statistics.last_message_date,
    ->            v1_topic_statistics.post_count,
    ->            v1_topic_statistics.post_count_total,
    ->            v1_topic_statistics.hits_count,
    ->            v1_topic_statistics.bot_hits_count,
    ->            v1_topic.profiled_topic,
    ->            v1_topic.deleted, v1_topic.closed, v1_topic.pinned, v1_topic.publish_delay, has_pinned_post,
    ->            v1_forum.deleted forum_deleted,
    ->            v1_topic.user_id, v1_topic.author, v1_topic.read_marker, v1_user.user_name,
    ->                v1_user.last_visit_date, v1_user.logout,
    ->            forum_id, v1_forum.name forum_name, is_poll, v1_topic.no_guests
    ->            from v1_topic
    ->            inner join v1_topic_statistics force index (v1_topic_statistics_lmdate_idx) on (v1_topic.id = v1_topic_statistics.topic_id)
    ->            inner join v1_forum on (v1_topic.forum_id = v1_forum.id)
    ->            left join v1_user on (v1_topic.user_id = v1_user.id)
    ->            where v1_topic.forum_id = 64 and v1_topic.deleted + v1_forum.deleted = 0
    ->  and v1_topic.pinned + v1_topic.publish_delay = 0
    ->            order by v1_topic_statistics.last_message_date desc
    ->            limit 0, 5;
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| EXPLAIN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| -> Limit: 5 row(s)  (cost=325298 rows=4.95) (actual time=0.346..0.417 rows=5 loops=1)
    -> Nested loop left join  (cost=325298 rows=4.95) (actual time=0.344..0.415 rows=5 loops=1)
        -> Nested loop inner join  (cost=309696 rows=4.95) (actual time=0.331..0.392 rows=5 loops=1)
            -> Index scan on v1_topic_statistics using V1_TOPIC_STATISTICS_LMDATE_IDX (reverse)  (cost=24.8 rows=99) (actual time=0.295..0.297 rows=12 loops=1)
            -> Filter: ((v1_topic.FORUM_ID = 64) and ((v1_topic.DELETED + '0') = 0) and ((v1_topic.PINNED + v1_topic.PUBLISH_DELAY) = 0))  (cost=0.25 rows=0.05) (actual time=0.0061..0.00614 rows=0.417 loops=12)
                -> Single-row index lookup on v1_topic using PRIMARY (ID=v1_topic_statistics.TOPIC_ID)  (cost=0.25 rows=1) (actual time=0.00555..0.00559 rows=1 loops=12)
        -> Single-row index lookup on v1_user using PRIMARY (ID=v1_topic.USER_ID)  (cost=0.252 rows=1) (actual time=0.00422..0.00426 rows=1 loops=5)
 |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

mysql>
...
Рейтинг: 0 / 0
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536501
basename
Скрыть профиль Поместить в игнор-лист
Участник
eNose [игнорируется] 

Планы уже отправил деду. Всё, что больше limit 0 10 - тормозит
...
Рейтинг: 0 / 0
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536509
basename
Скрыть профиль Поместить в игнор-лист
Участник
Код
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
| -> Limit: 11 row(s)  (cost=325341 rows=11) (actual time=0.693..5673 rows=10 loops=1)
    -> Nested loop left join  (cost=325341 rows=11) (actual time=0.691..5673 rows=10 loops=1)
        -> Nested loop inner join  (cost=309738 rows=11) (actual time=0.669..5673 rows=10 loops=1)
            -> Index scan on v1_topic_statistics using V1_TOPIC_STATISTICS_LMDATE_IDX (reverse)  (cost=54.8 rows=219) (actual time=0.61..2195 rows=1.24e+6 loops=1)
            -> Filter: ((v1_topic.FORUM_ID = 64) and ((v1_topic.DELETED + '0') = 0) and ((v1_topic.PINNED + v1_topic.PUBLISH_DELAY) = 0))  (cost=0.25 rows=0.05) (actual time=0.00269..0.00269 rows=8.05e-6 loops=1.24e+6)
                -> Single-row index lookup on v1_topic using PRIMARY (ID=v1_topic_statistics.TOPIC_ID)  (cost=0.25 rows=1) (actual time=0.00241..0.00244 rows=1 loops=1.24e+6)
        -> Single-row index lookup on v1_user using PRIMARY (ID=v1_topic.USER_ID)  (cost=0.252 rows=1) (actual time=0.00331..0.00334 rows=1 loops=10)
 |

 | -> Limit: 10 row(s)  (cost=325334 rows=9.95) (actual time=0.315..0.421 rows=10 loops=1)
    -> Nested loop left join  (cost=325334 rows=9.95) (actual time=0.29..0.395 rows=10 loops=1)
        -> Nested loop inner join  (cost=309731 rows=9.95) (actual time=0.281..0.371 rows=10 loops=1)
            -> Index scan on v1_topic_statistics using V1_TOPIC_STATISTICS_LMDATE_IDX (reverse)  (cost=49.8 rows=199) (actual time=0.264..0.268 rows=24 loops=1)
            -> Filter: ((v1_topic.FORUM_ID = 64) and ((v1_topic.DELETED + '0') = 0) and ((v1_topic.PINNED + v1_topic.PUBLISH_DELAY) = 0))  (cost=0.25 rows=0.05) (actual time=0.004..0.00405 rows=0.417 loops=24)
                -> Single-row index lookup on v1_topic using PRIMARY (ID=v1_topic_statistics.TOPIC_ID)  (cost=0.25 rows=1) (actual time=0.00359..0.00362 rows=1 loops=24)
        -> Single-row index lookup on v1_user using PRIMARY (ID=v1_topic.USER_ID)  (cost=0.252 rows=1) (actual time=0.00209..0.00213 rows=1 loops=10)
 |
loops=1.24e+6 - вот хрень порылась
...
Рейтинг: 0 / 0
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536531
basename
Скрыть профиль Поместить в игнор-лист
Участник
eNose  12.09.2023, 15:45
[игнорируется]
пусть сначала сделает селект каунт и если тем меньше чем на страницу - убирает лимит
Передал
...
Рейтинг: 0 / 0
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536717
basename
Скрыть профиль Поместить в игнор-лист
Участник
said  12.09.2023, 18:34
[игнорируется]
1. мускул все запросы - кеширует
2. глупо делать какие-то там сравнения с включенным кешированием
3. дед - долбоёб, его говно тормозило и будет тормозить ещё больше, потому что он - долбоёб
4. базя - мудак и не понимает, что за проёбы долбоёба, расхлёбывать будет - он, базя, а не говнокодер
Несколько раз выполняли подряд. не кэшируют. Ну надо же разобраться, что не так. Скорее всего удастся подправить. Ну это же бред, что подфорум из 12 тем открывается 6 секунд, а подфорум из 300 000 тем - 200 ms. Планы текущих запросов - выше.. Там видна хрень с loops.Это уже шаг вперёд.
...
Рейтинг: 0 / 0
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536723
basename
Скрыть профиль Поместить в игнор-лист
Участник
said  12.09.2023, 18:52
[игнорируется]
basename  12.09.2023, 18:50
[игнорируется]
Несколько раз выполняли подряд. не кэшируют
кеширует с первого запроса
блять, как можно быть таким тупым?
если он несколько раз подряд выполняется 6 секунд, с первого или с десятого. Что он там кэширует то? В том числе после рестарта сразу. Он ещё буфер свой накачать не успевает данными даже.
...
Рейтинг: 1 / 0
Нравится: Гарыныч
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536822
basename
Скрыть профиль Поместить в игнор-лист
Участник
Sparrow  12.09.2023, 19:26
[игнорируется]
Памяти серверу мало. И вообще лимитс зачем?
Сейчас точно достаточно
pasted_image.png
...
Рейтинг: 1 / 0
Нравится: Гарыныч
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536825
basename
Скрыть профиль Поместить в игнор-лист
Участник
said  12.09.2023, 19:35
[игнорируется]
базя, если сам гуглить нихуя не умеешь, на, кролик за тебя опять всё нагуглил
ликбез по кешированию мускула
Про это я знаю, но эти советы по оптимизации актуальны были раньше, сейчас не актуальны. В 8 версии всё изменилось
pasted_image.png
...
Рейтинг: 0 / 0
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536829
basename
Скрыть профиль Поместить в игнор-лист
Участник
eNose  12.09.2023, 19:48
[игнорируется]
Базя молодец конечно.
Нашел бесплатного долбоёба, который поработал.
Респект Базе.
Я попросил, если ему будет интересно, бесплатно я никого не искал. Предлагал по-возможности как-то отблагодарить, КРолик от всего отказался, даже от несчастной виртуалки. Ну я не могу бегать умолять всё время.
...
Рейтинг: 1 / 0
Нравится: Гарыныч
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536832
basename
Скрыть профиль Поместить в игнор-лист
Участник
said  12.09.2023, 19:51
[игнорируется]
базя свой язык вжопу засунул
этого и следовало ожидать
я ещё даже пост твой не успел прочитать.
...
Рейтинг: 1 / 0
Нравится: Гарыныч
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536834
basename
Скрыть профиль Поместить в игнор-лист
Участник
eNose  12.09.2023, 19:49
[игнорируется]
said  12.09.2023, 19:48
[игнорируется]
eNose  12.09.2023, 19:48
[игнорируется]
Базя молодец конечно.
Нашел бесплатного долбоёба, который поработал.
Респект Базе.
ждём ответ бази

базя, алё
Ну он то тебе скажет спасибо, конечно.

Даже я скажу: СПАСИБО.

На этом всё. Денег не жди, иди нахой!
Ну я хотел предложить как то в том числе материально, чтобы не обидно, ну например, у него нет девайсов для тестирования мобильных приложений, чата в том числе. Что я должен сделать? Самоубиться, если он отказывается иобижается?
...
Рейтинг: 0 / 0
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536835
basename
Скрыть профиль Поместить в игнор-лист
Участник
eNose  12.09.2023, 20:02
[игнорируется]
said  12.09.2023, 19:51
[игнорируется]
базя свой язык вжопу засунул
этого и следовало ожидать
А тебе надо медаль от Бази?

Сам подумай:
работал бесплатно? Да.
всеобщий респект получил? Нет.
считают тебя гандоном? Да.

Выводы делай сам.
Ну я то не считаю.
...
Рейтинг: 0 / 0
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536838
basename
Скрыть профиль Поместить в игнор-лист
Участник
Гарыныч  12.09.2023, 19:41
[игнорируется]
said  12.09.2023, 19:35
[игнорируется]
базя, если сам гуглить нихуя не умеешь, на, кролик за тебя опять всё нагуглил
ликбез по кешированию мускула
а какая версия муСкуля у Деды и Бази?
Цитата 
[игнорируется]
Примечание: Кэш запросов устарел в версии MySQL 5.7.20 и был удален в MySQL 8.0, но он по-прежнему является мощным инструментом и его можно использовать в тех версиях MySQL, которые поддерживают его. В более новых версиях MySQL можно использовать альтернативные сторонние инструменты для оптимизации производительности базы данных MySQL (такие как ProxySQL).
Цитата 
[игнорируется]
Работает на версии PHP 8.x или выше.
Поддерживает системы управления базами данных:
MySQL 8.0.x или выше,
Microsoft SQL Server 2005 или выше.
8.0.33.

При этом, в МарииДБ Дед совсем не гарантирует работу, раньше он проверял, работало.. (Сириус там уже сталкивался с чем-то)
...
Рейтинг: 1 / 0
Нравится: Гарыныч
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536839
basename
Скрыть профиль Поместить в игнор-лист
Участник
eNose  12.09.2023, 20:08
[игнорируется]
basename  12.09.2023, 20:07
[игнорируется]
eNose  12.09.2023, 19:49
[игнорируется]
said  12.09.2023, 19:48
[игнорируется]
eNose  12.09.2023, 19:48
[игнорируется]
...
ждём ответ бази

базя, алё
Ну он то тебе скажет спасибо, конечно.

Даже я скажу: СПАСИБО.

На этом всё. Денег не жди, иди нахой!
Ну я хотел предложить как то в том числе материально, чтобы не обидно, ну например, у него нет девайсов для тестирования мобильных приложений, чата в том числе. Что я должен сделать? Самоубиться, если он отказывается иобижается?
Он ненавидит мобильные приложения и тех кто их использует
он как-то сказал, что у него нет возможности их тестировать.
...
Рейтинг: 0 / 0
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536845
basename
Скрыть профиль Поместить в игнор-лист
Участник
eNose  12.09.2023, 20:11
[игнорируется]
basename  12.09.2023, 20:10
[игнорируется]
eNose  12.09.2023, 20:08
[игнорируется]
basename  12.09.2023, 20:07
[игнорируется]
eNose  12.09.2023, 19:49
[игнорируется]
...
Ну я хотел предложить как то в том числе материально, чтобы не обидно, ну например, у него нет девайсов для тестирования мобильных приложений, чата в том числе. Что я должен сделать? Самоубиться, если он отказывается иобижается?
Он ненавидит мобильные приложения и тех кто их использует
он как-то сказал, что у него нет возможности их тестировать.
Смартфона нет? Или компа нет с эмулятором андроида?
Смартфона у него нет. Эмулятор андроида мы обсуждали давно ещё, он мне показывал, там херня выходит. Можно было отправить ему iphone SE, на андроиде что-нибудь и планшет. Для тестирования совсем не обязательно новое, и стоит это всё недорого. Я бы и сам отправил, хоть у меня увы с деньгами хреново, он не захотел вообще ничего. Даже виртуалка с приемлимой скоростью работы ему не нужна. Ну на хрен мне за это платить?
...
Рейтинг: 0 / 0
Вопросы по форуму / Долгое открытие маленьких подфорумов на рескуле
    #536846
basename
Скрыть профиль Поместить в игнор-лист
Участник
Ладно, пошёл спать я.
...
Рейтинг: 1 / 0
Нравится: Гарыныч
25 сообщений из 32, страница 1 из 2
Форумы / Вопросы по форуму [закрыт для гостей] / Долгое открытие маленьких подфорумов на рескуле, Поиск: Искать сообщения, созданные автором: basename  
Читали тему (3): Анонимы (3)
Игнорируют тему (1): erbol
Читали форум (9): Анонимы (8), Bing Bot 1 мин.
Пользователи онлайн (87): Анонимы (77), Tabula Rasa, IT-Клоп, Ибрагимов Мага 82, Bing Bot 1 мин., Брюквенные годы 1 мин., anonymous 2 мин., prostozevs 3 мин., Кусь 4 мин., Гарыныч 4 мин., Biene Maja 7 мин.
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]