powered by simpleCommunicator - 2.0.18     © 2024 Programmizd 02
Map
Форумы / Вопросы по форуму [игнор отключен] [закрыт для гостей] / Долгое открытие подфорумов с большим количеством тем
8 сообщений из 33, страница 2 из 2
Долгое открытие подфорумов с большим количеством тем
    #40138039
Фотография basename
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Код: SQL
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.
/* Java */

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_statistics
           inner join v1_topic
            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 = 59 and v1_topic.deleted + v1_forum.deleted = 0
 and v1_topic.pinned + v1_topic.publish_delay = 0
           order by last_message_date desc
           limit 0, 40;
pasted_image.png
...
Рейтинг: 0 / 0
Долгое открытие подфорумов с большим количеством тем
    #40138040
Фотография basename
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Для истории, с параллельного форума, попытка локализации и устранения проблемы.
...
Рейтинг: 0 / 0
Долгое открытие подфорумов с большим количеством тем
    #40138041
Фотография basename
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
basename 
[игнорируется]
eNose 
[игнорируется]
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
Долгое открытие подфорумов с большим количеством тем
    #40138042
Фотография basename
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
basename 
[игнорируется]
eNose 
[игнорируется]
пусть деда на "хорошем запросе" посмотрит план и хинтами выставит принудительно использование нужных индексов
Планы
Код
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
Долгое открытие подфорумов с большим количеством тем
    #40138043
Фотография basename
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
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
Долгое открытие подфорумов с большим количеством тем
    #40138044
Фотография basename
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
eNose 
[игнорируется]
-> 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)
eNose 
[игнорируется]
пусть сначала сделает селект каунт и если тем меньше чем на страницу - убирает лимит
eNose 
[игнорируется]
basename

http://www.sql-tutorial.ru/ru/book_row_number_function/page2.html

можно пронумеровать строки и во внешнем запросе через where сделать аналог limit.
...
Рейтинг: 0 / 0
Долгое открытие подфорумов с большим количеством тем
    #40138071
Фотография basename
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Вышел патч 2.0.5 (17.09.2023)

Проблема частично решена
- маленькие и большие подфорумы открываюстя быстро
- средние в пределах приемлемого времени
...
Рейтинг: 1 / 0
Нравится: Гарыныч
Долгое открытие подфорумов с большим количеством тем
    #40138211
Администратор
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Администратор
Проблема практически полностью решена в патче 2.0.6

В данный момент сохраняется проблема с долгим открытием последней страницы при наличии большого количества страницы в подфорумах.

Связано с особенностями MySQL
Цитата 
[игнорируется]
Large limit offsets degrade the performance of most databases, but it is especially egregious in MySQL.
https://emmer.dev/blog/the-dangers-of-offset-with-mysql/
...
Рейтинг: 0 / 0
8 сообщений из 33, страница 2 из 2
Форумы / Вопросы по форуму [игнор отключен] [закрыт для гостей] / Долгое открытие подфорумов с большим количеством тем
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали тему (1): Анонимы (1)
Читали форум (1): Анонимы (1)
Пользователи онлайн (5): Анонимы (3), Yandex Bot, Bing Bot 2 мин.
x
x
Закрыть


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