Òÿæåëûå çàïðîñû Òÿæåëûå çàïðîñû
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Òÿæåëûå çàïðîñû

Started by GeXu3, January 07, 2008, 07:12:21 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GeXu3

Ïîêîïàëñÿ âíóòðè - íåìíîãî ïåðåïóãàëñÿ. Êîãäà â ãàëåðåå 1000-10000 ôîòîãðàôèé òî åùå íè÷åãî, íî êîãäà 50 000 - ëîæèò âñ¸ íàôèã. Âîò, íàïðèìåð, ïîäîáíàÿ øòóêà:
[17] => SELECT aid FROM cpg132_albums as a WHERE category>=10000 (10.419s)
Ëîæèò âåñü ñêðèïò ê ÷åðîòîâé ìàòåðè... Îñòàëüíûå æå çàïðîñû èä¸ò áîëåå-ìåíåå íîðìàëüíî:
    [0] => SELECT extension, mime, content, player FROM cpg132_filetypes; (0.002s)
    [1] => select * from cpg132_plugins order by priority asc; (0s)
    [2] => delete from `gex_mp20061015`.cpg132_sessions where time<1199725143 and remember=0; (0.042s)
    [3] => delete from `gex_mp20061015`.cpg132_sessions where time<1198519143; (0.133s)
    [4] => select user_id from `gex_mp20061015`.cpg132_sessions where session_id=md5("812ea7bf67766adbbf56943d5de2c3daee24ce1ce70881e5e1a018c69b95e1c7"); (0.044s)
    [5] => select user_id as id, user_password as password from `gex_mp20061015`.cpg132_users where user_id=1 (0.097s)
    [6] => SELECT u.user_id AS id, u.user_name AS username, u.user_password AS password, u.user_group+100 AS group_id FROM `gex_mp20061015`.cpg132_users AS u INNER JOIN `gex_mp20061015`.cpg132_usergroups AS g ON u.user_group=g.group_id WHERE u.user_id='1' (0.019s)
    [7] => SELECT user_group_list FROM `gex_mp20061015`.cpg132_users AS u WHERE user_id='1' and user_group_list <> ''; (0s)
    [8] => SELECT MAX(group_quota) as disk_max, MIN(group_quota) as disk_min, MAX(can_rate_pictures) as can_rate_pictures, MAX(can_send_ecards) as can_send_ecards, MAX(upload_form_config) as ufc_max, MIN(upload_form_config) as ufc_min, MAX(custom_user_upload) as custom_user_upload, MAX(num_file_upload) as num_file_upload, MAX(num_URI_upload) as num_URI_upload, MAX(can_post_comments) as can_post_comments, MAX(can_upload_pictures) as can_upload_pictures, MAX(can_create_albums) as can_create_albums, MAX(has_admin_access) as has_admin_access, MIN(pub_upl_need_approval) as pub_upl_need_approval, MIN( priv_upl_need_approval) as  priv_upl_need_approval FROM cpg132_usergroups WHERE group_id in (1) (0s)
    [9] => SELECT group_name FROM  cpg132_usergroups WHERE group_id= 1 (0s)
    [10] => update `gex_mp20061015`.cpg132_sessions set time='1199728743' where session_id=md5('812ea7bf67766adbbf56943d5de2c3daee24ce1ce70881e5e1a018c69b95e1c7'); (0.005s)
    [11] => SELECT user_favpics FROM cpg132_favpics WHERE user_id = 1 (0.077s)
    [12] => DELETE FROM cpg132_mod_online WHERE last_action < NOW() - INTERVAL 10 MINUTE (0.023s)
    [13] => REPLACE INTO cpg132_mod_online (user_id, user_name, user_ip, last_action) VALUES ('1', 'GeX', '10.6.18.207', NOW()) (0.017s)
    [14] => DELETE FROM cpg132_banned WHERE expiry < '2008-01-07 20:59:07' (0.038s)
    [15] => SELECT * FROM cpg132_banned WHERE (ip_addr='10.6.18.207' OR ip_addr='10.6.18.207' OR user_id=1) AND brute_force=0 (0s)
    [16] => SELECT cid, name, description, thumb FROM cpg132_categories WHERE parent = ''  ORDER BY pos (0.012s)
    [17] => SELECT aid FROM cpg132_albums as a WHERE category>=10000 (10.419s)
    [18] => SELECT count(*) FROM cpg132_pictures as p, cpg132_albums as a WHERE p.aid = a.aid AND approved='YES' AND category >= 10000 (0.25s)
    [19] => SELECT cid, name, description, thumb FROM cpg132_categories WHERE parent = '1'  ORDER BY pos (0s)
    [20] => SELECT aid FROM cpg132_albums WHERE category = 2 (0s)
    [21] => SELECT count(*) FROM cpg132_pictures as p, cpg132_albums as a WHERE p.aid = a.aid AND approved='YES' AND category = 2 (0.001s)
    [22] => SELECT count(*) FROM cpg132_albums as a WHERE category = '2' (0s)
    [23] => SELECT a.aid, a.title, a.description, visibility, filepath, filename, url_prefix, pwidth, pheight FROM cpg132_albums as a LEFT JOIN cpg132_pictures as p ON a.thumb=p.pid WHERE category=2 ORDER BY a.pos LIMIT 0,6 (0.001s)
    [24] => SELECT a.aid, count( p.pid )  AS pic_count, max( p.pid )  AS last_pid, max( p.ctime )  AS last_upload, a.keyword FROM cpg132_albums AS a  LEFT JOIN cpg132_pictures AS p ON a.aid = p.aid AND p.approved =  'YES' WHERE a.aid IN (6140, 4276, 4074, 4010, 3887, 3007)GROUP BY a.aid (0.003s)
    [25] => SELECT filepath, filename, url_prefix, pwidth, pheight FROM cpg132_pictures WHERE pid='56216' (0.001s)
    [26] => SELECT cid, name, description, thumb FROM cpg132_categories WHERE parent = '2'  ORDER BY pos (0.018s)
    [27] => SELECT aid FROM cpg132_albums WHERE category = 12 (0.011s)
    [28] => SELECT count(*) FROM cpg132_pictures as p, cpg132_albums as a WHERE p.aid = a.aid AND approved='YES' AND category = 12 (0.045s)
    [29] => SELECT aid FROM cpg132_albums WHERE category = 7 (0.014s)
    [30] => SELECT count(*) FROM cpg132_pictures as p, cpg132_albums as a WHERE p.aid = a.aid AND approved='YES' AND category = 7 (0.018s)
    [31] => SELECT aid FROM cpg132_albums WHERE category = 6 (0.011s)
    [32] => SELECT count(*) FROM cpg132_pictures as p, cpg132_albums as a WHERE p.aid = a.aid AND approved='YES' AND category = 6 (0.085s)
    [33] => SELECT aid FROM cpg132_albums WHERE category = 3 (0.006s)
    [34] => SELECT count(*) FROM cpg132_pictures as p, cpg132_albums as a WHERE p.aid = a.aid AND approved='YES' AND category = 3 (0.005s)
    [35] => SELECT count(*) FROM cpg132_albums as a WHERE category = '3' (0.004s)
    [36] => SELECT a.aid, a.title, a.description, visibility, filepath, filename, url_prefix, pwidth, pheight FROM cpg132_albums as a LEFT JOIN cpg132_pictures as p ON a.thumb=p.pid WHERE category=3 ORDER BY a.pos LIMIT 0,10 (0.005s)
    [37] => SELECT a.aid, count( p.pid )  AS pic_count, max( p.pid )  AS last_pid, max( p.ctime )  AS last_upload, a.keyword FROM cpg132_albums AS a  LEFT JOIN cpg132_pictures AS p ON a.aid = p.aid AND p.approved =  'YES' WHERE a.aid IN (3108, 73, 74, 75, 76, 77, 79, 80, 81, 82)GROUP BY a.aid (0.008s)
    [38] => SELECT cid, name, description, thumb FROM cpg132_categories WHERE parent = '3'  ORDER BY pos (0.014s)
    [39] => SELECT aid FROM cpg132_albums as a WHERE category = '0' (0.012s)
    [40] => SELECT COUNT(*) FROM cpg132_pictures WHERE approved = 'NO' (0.066s)
    [41] => SELECT count(*) FROM cpg132_albums as a WHERE category = '0' (0.008s)
    [42] => SELECT COUNT(*) from cpg132_pictures WHERE approved = 'YES'  (0.064s)
    [43] => SELECT * FROM cpg132_pictures WHERE approved = 'YES'  ORDER BY pid DESC  LIMIT 0 ,8 (0.022s)
    [44] => SELECT COUNT(*) FROM `gex_mp20061015`.cpg132_users (0.08s)
    [45] => SELECT COUNT(*) FROM cpg132_mod_online (0.018s)
    [46] => SELECT COUNT(*) FROM cpg132_mod_online WHERE user_id <> 0 (0.084s)
    [47] => SELECT user_id, user_name FROM `gex_mp20061015`.cpg132_users ORDER BY user_id DESC LIMIT 1 (0.059s)
    [48] => SELECT user_id, user_name FROM cpg132_mod_online WHERE user_id <> 0 (0.015s)

 èòîãå èìååì:
Page generated in 15.902 seconds - 49 queries in 11.856 seconds
Ãäå 10 ñåêóíä äåëàëñÿ îòîò óêàçàíûé ñàìûì ïåðâûì çàïðîñ.
Ýòî ìåðÿë âî âðåìÿ âûñîêîé íàãðóçêè íà ñåðâåð (ñåðâåðó òÿæåëî, òî ÿñíî, íî è òàêèå çàïðîñû - íå äåëî).

Äàííûé çàïðîñ âñòðå÷àåööî â index.php è includes/functions.inc.php ... ïðîáîâàë äîïèñàòü â êîíåö limit 0,1, íî îíî âûçûâàëî äîâîëüíî íåïðåäñêàçóåìûå ãëþêè.
Ìîæåò êòî äîäóìàëñÿ êàê åãî ïåðåïèñàòü òàê, ÷òîá îíî è ðàáîòàëî, è íå óáèâàëî ñåðâåð? Èëè êàê îïòèìèçèðîâàòü áàçó äàííûõ ÷¸á îíî åãî íå ëîæèëî.

Ç.Û.: à â 1.5 ñëó÷àéíî íå èçáàâèëèñü îò âñåõ ýòèõ òÿæåëîâåñîâ? èáî ïðèâåä¸ííûé âûøå çàïðîñ - âåðõóøêà àéñáåðãà. Ïî÷òè âåçäå ïî êîäó ïîïàäàþööî çàïðîñû íà count, êîòîðûå, ïðè òàáëèöàõ â íåñêîëüêîñîòòûñÿ÷ çàïèñåé, òîæ íåêèñëî ëîæàò ñåðâåð.

awf

êàæèñü â ýòîé âåòêå îáñóæäàþò ïðîáëåìó ñ çàïðîñàìè:

http://forum.coppermine-gallery.net/index.php?topic=15653.0

GeXu3

Õà! Îíè ðåøèëè ýòó ïðîáëåìó áàíàëüíûì êåøèðîâàíèåì. ÓìíÎ. Íàäî ïðîâåðÿòü íà ïðàêòèêå. Ñïàñèáî. Î ðåçóëüòàòå îòïèøóñü :)