ÈçºÎÓÅ»¯MysqlǧÍò¼¶¿ìËÙ·ÖÒ³,limitÓÅ»¯¿ìËÙ·ÖÒ³
MySQLÊý¾Ý¿âÓÅ»¯´¦ÀíʵÏÖǧÍò¼¶¿ìËÙ·ÖÒ³·ÖÎö£¬À´¿´Ï°ɡ£
Êý¾Ý±í collect ( id, title ,info ,vtype) ¾ÍÕâ4¸ö×ֶΣ¬ÆäÖÐ title Óö¨³¤£¬info ÓÃtext, id ÊÇÖð½¥£¬vtypeÊÇtinyint£¬vtypeÊÇË÷Òý¡£ÕâÊÇÒ»¸ö»ù±¾µÄÐÂÎÅϵͳµÄ¼òµ¥Ä£ÐÍ¡£ÏÖÔÚÍùÀïÃæÌî³äÊý¾Ý£¬Ìî³ä10ÍòƪÐÂÎÅ¡£
×îºócollect Ϊ 10ÍòÌõ¼Ç¼£¬Êý¾Ý¿â±íÕ¼ÓÃÓ²ÅÌ1.6G¡£OK ,¿´ÏÂÃæÕâÌõsqlÓï¾ä£º
select id,title from collect limit 1000,10; ºÜ¿ì£»»ù±¾ÉÏ0.01Ãë¾ÍOK£¬ÔÙ¿´ÏÂÃæµÄ
select id,title from collect limit 90000,10; ´Ó9ÍòÌõ¿ªÊ¼·ÖÒ³£¬½á¹û£¿
8-9ÃëÍê³É£¬my god ÄijöÎÊÌâÁË£¿£¿£¿£¿ÆäʵҪÓÅ»¯ÕâÌõÊý¾Ý£¬ÍøÉÏÕҵõ½´ð°¸¡£¿´ÏÂÃæÒ»ÌõÓï¾ä:
select id from collect order by id limit 90000,10; ºÜ¿ì£¬0.04Ãë¾ÍOK¡£ Ϊʲô£¿ÒòΪÓÃÁËidÖ÷¼ü×öË÷Òýµ±È»¿ì¡£ÍøÉϵĸķ¨ÊÇ£º
select id,title from collect where id>=(select id from collect order by id limit 90000,1) limit 10;
Õâ¾ÍÊÇÓÃÁËid×öË÷ÒýµÄ½á¹û¡£¿ÉÊÇÎÊÌ⸴ÔÓÄÇôһµãµã£¬¾ÍÍêÁË¡£¿´ÏÂÃæµÄÓï¾ä
select id from collect where vtype=1 order by id limit 90000,10; ºÜÂý£¬ÓÃÁË8-9Ã룡
µ½ÁËÕâÀïÎÒÏàÐźܶàÈË»áºÍÎÒÒ»Ñù£¬ÓбÀÀ£¸Ð¾õ£¡vtype ×öÁËË÷ÒýÁË°¡£¿Ôõô»áÂýÄØ£¿vtype×öÁËË÷ÒýÊDz»´í£¬ÄãÖ±½Ó select id from collect where vtype=1 limit 1000,10; ÊǺܿìµÄ£¬»ù±¾ÉÏ0.05Ã룬¿ÉÊÇÌá¸ß90±¶£¬´Ó9Íò¿ªÊ¼£¬ÄǾÍÊÇ0.05*90=4.5ÃëµÄËÙ¶ÈÁË¡£ºÍ²âÊÔ½á¹û8-9Ãëµ½ÁËÒ»¸öÊýÁ¿¼¶¡£´ÓÕâÀ↑ʼÓÐÈËÌá³öÁË·Ö±íµÄ˼·£¬Õâ¸öºÍdiscuz ÂÛ̳ÊÇÒ»ÑùµÄ˼·¡£Ë¼Â·ÈçÏ£º
½¨Ò»¸öË÷Òý±í£º t (id,title,vtype) ²¢ÉèÖóɶ¨³¤£¬È»ºó×ö·ÖÒ³£¬·ÖÒ³³ö½á¹ûÔÙµ½ collect ÀïÃæÈ¥ÕÒinfo ¡£ ÊÇ·ñ¿ÉÐÐÄØ£¿ÊµÑéϾÍÖªµÀÁË¡£
10ÍòÌõ¼Ç¼µ½ t(id,title,vtype) ÀÊý¾Ý±í´óС20M×óÓÒ¡£ÓÃ
select id from t where vtype=1 order by id limit 90000,10; ºÜ¿ìÁË¡£»ù±¾ÉÏ0.1-0.2Ãë¿ÉÒÔÅÜÍꡣΪʲô»áÕâÑùÄØ£¿ÎÒ²ÂÏëÊÇÒòΪcollect Êý¾ÝÌ«¶à£¬ËùÒÔ·ÖÒ³ÒªÅܺܳ¤µÄ·¡£limit ÍêÈ«ºÍÊý¾Ý±íµÄ´óСÓйصġ£ÆäʵÕâÑù×ö»¹ÊÇÈ«±íɨÃ裬ֻÊÇÒòΪÊý¾ÝÁ¿Ð¡£¬Ö»ÓÐ10Íò²Å¿ì¡£OK£¬ À´¸ö·è¿ñµÄʵÑ飬¼Óµ½100ÍòÌõ£¬²âÊÔÐÔÄÜ¡£
¼ÓÁË10±¶µÄÊý¾Ý£¬ÂíÉÏt±í¾Íµ½ÁË200¶àM£¬¶øÇÒÊǶ¨³¤¡£»¹ÊǸղŵIJéѯÓï¾ä£¬Ê±¼äÊÇ0.1-0.2ÃëÍê³É£¡·Ö±íÐÔÄÜûÎÊÌ⣿´í£¡ÒòΪÎÒÃǵÄlimit»¹ÊÇ9Íò£¬ËùÒÔ¿ì¡£¸ø¸ö´óµÄ£¬90Íò¿ªÊ¼
select id from t where vtype=1 order by id limit 900000,10; ¿´¿´½á¹û£
Ïà¹ØÎĵµ£º
ÔÚ½üÆÚµÄÏîĿά»¤¹¤×÷ÖУ¬Ê±³£³öÏÖÖ÷¼üÖظ´µÄÒì³£¡£¾¹ýһϵÁÐ×ÊÁϵIJéѯ֮ºó£¬·¢ÏÖʱhibernateÓ³ÉäÎļþÅäÖÃÎÊÌâ¡£
mysqlÌṩÖ÷¼ü“×Ô¶¯ÔöÁ¿”µÄÅäÖã¬Ö¸¶¨¸ÃÀàÐ͵ÄÖ÷¼ü£¬mysqlÄܹ»×Ô¶¯¼ÓÒ»¡£
ÔÚhibernateÓ³ÉäÎļþÖУ¬¹ØÓÚÖ÷¼üµÄÅäÖò»ÄÜÊÇ
<generator class="increment"&g ......
mysqladmin extended (¾ø¶ÔÖµ)
ÖصãÈ¥¼àÊÓµÄÖµÓУº
* Slave_running:Èç¹ûϵͳÓÐÒ»¸ö´Ó¸´ÖÆ·þÎñÆ÷£¬Õâ¸öÖµÖ¸Ã÷ÁË´Ó·þÎñÆ÷µÄ½¡¿µ¶È
* Threads_connected:µ±Ç°¿Í»§¶ËÒÑÁ¬½ÓµÄÊýÁ¿¡£Õâ¸öÖµ»áÉÙÓÚÔ¤ÉèµÄÖµ£¬µ«ÄãÒ²ÄܼàÊÓµ½Õâ¸öÖµ½Ï´ó£¬Õâ¿É±£Ö¤¿Í»§¶ËÊÇ´¦ÔÚ»îԾ״̬¡£
* Threads_running:Èç¹ûÊý¾Ý¿â³¬¸ººÉÁË£¬Ä㽫»áµÃµ½Ò»¸ö ......
http://hi.baidu.com/thinkinginlamp/blog/item/a352918fe70d96fd503d925e.html
2009Äê01ÔÂ12ÈÕ ÐÇÆÚÒ» ÏÂÎç 08:35
×÷ÕߣºÀÏÍõ
ÔÚÍøÉÏËæ±ãËÑËÑ£¬¾ÍÄÜÕÒµ½´ó°ÑµÄ¹ØÓÚMySQLÓÅ»¯µÄÎÄÕ£¬²»¹ýÀïÃæºÜ¶à¶¼²»×¼È·£¬Ëµ¸ö³£¼ûµÄ£º
SELECT a from ... WHERE b = ...
Ò»°ãÀ´Ëµ£¬ºÜ¶àÎÄÕ»á¸æ½ëÄãÀàËÆÕâÑùµÄ²éѯ£¬²»ÒªÔÚ“a ......
1.±àдshell½Å±¾
vi /data/www/project_name/bin/mysql_backup.sh
#!/bin/bash
#This is a ShellScript For Auto DB Backup
#Powered by liuzheng
#ϵͳ±äÁ¿¶¨Òå
DBName=test
DBUser=root
DBPasswd=123456
BackupPath=/tmp/mysql_backup/
NewFile="$BackupPath"db$(date +%y%m%d ......