ÓÐÁ½¸ö±í£¬ÊýÁ¿¼¶ÔÚ3000w×óÓÒ£¬
Ïë²é¿´¾ßÌåµÄÊýÁ¿£¬ÓÃselect Count(*) ËÙ¶ÈÌ«Âý£¬
֮ǰ¿´µ½ËµÔÚsysindexesÖÐÓÐrows ÁУ¬ µ«ÊÇÎÒ·¢ÏÖ£¬ÕâÁ½¸öµÄÖµ²»Ò»Ñù£¬Ôõô»ØÊ°¡£¿
лл
ÓÐÈËÄܻشðÒ»ÏÂÂð? ²»ÊǺÜÃ÷°×°¡
ÒýÓÃ
ÓÐÁ½¸ö±í£¬ÊýÁ¿¼¶ÔÚ3000w×óÓÒ£¬
Ïë²é¿´¾ßÌåµÄÊýÁ¿£¬ÓÃselect Count(*) ËÙ¶ÈÌ«Âý£¬
֮ǰ¿´µ½ËµÔÚsysi ......
Á½¸ö¶à±íÁª²é¶àÓï¾ä
µÚÒ»¸ö±íÊÇ A BÁ½±í²é³ö
ID
1
2
3
4
5
µÚ¶þ¸ö±íÉÌ A B CÈý±í²é³ö
3
4
5
ÎÊÈçºÎ°ÑʣϵÄ1£¬2Ò²²é³öÀ´
×îºÃÌù³öSQLÓï¾ä
union all ??
»òÕß×óÁ¬½Ó
SQL code:
select * from a left join b on a.id=b.id
°ï¶¥£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡
Éæ¼°Êý¾Ý¿â±íµÄÉè¼Æ£¬Ä ......
Ò»±í
ÐÕÃû | 1 | 2 | 3 | 4 | 5 |¡£¡£¡£¡£¡£¡£
ÕÅÈý ʼ٠²¡¼Ù ʼ٠²¡¼Ù ²¡¼Ù¡£¡£¡£¡£¡£
ÀîËÄ »é¼Ù ³ö²î ³ö²î ³ö²î ³ö²î
ÈçºÎµÃ³ö
ÐÕÃû ʼ٠²¡¼Ù »é¼Þ ³ö²î¡£¡£¡£¡£
ÕÅÈý 2 3 0 0
ÀîËÄ 0 0 1 4
¼ÙÈçÐкÍÁеÄÄÚÈݶ¼Êǹ̶¨µÄ£¬¿ ......
ÇóÒ»ÌõSQLÓï¾ä¡£ÈçÏÂ
±í a
id Ö÷¼ü
²¿ÃÅ id
Ô±¹¤ÐÕÃû
ѧÀú
±í b
id Ö÷¼ü
²¿ÃÅÃû
±í c
ѧÀú id
ѧÀúÃû
Çó±í
²¿ÃÅa ²¿ÃÅb ²¿ÃÅc ²¿ÃÅd
³õÖÐ x x x x
¸ßÖÐ x x x x
´óר x x x x
´óѧ x x x x
ͳ¼Æ ÈËÊý
°ï¶¥~~
x x x x &n ......
дһ¸öSQlÓï¾äµÃµ½Ò»¸ö±íµÄ×îºóÒ»ÐеÄÖµ£¿
SQL code:
select top 1 * from tb order by id desc
Êý¾Ýû¹æÂÉ£¿1Â¥µÄÓï¾ä³ý·ÇÄãidÊÇ×ÔÔöÁС£·ñÔò²»ºÃ´¦Àí¡£
SQL code:
select top 1 * from tb order by id desc
Èç¹ûÓÐidµÄ»°¡£
Ó¦¸Ã°ÑÄãÕâ¸ö±íµÄÌØÕ÷˵³öÀ´£¬±ÈÈçÓÐʲô±È½ÏÌØÊâµÄ×ֶΡ£¡£±ÈÈç×ÔÔöÁеȡ£
Èç¹û ......
id a b
-----------
1 2 12
1 1 100
1 2 123
1 1 130
1 2 153
1 1 171
1 1 188
1 2 200
1 2 222
1 1 234
1 2 333
1 2 344
1 2 411
ÔʼÊý¾Ý°´ÕÕbÁÐÅÅÐò£¬Õý³£Êý¾ÝaÁÐÊÇ1£¬2½»Ì棬Ȼºó·Ö±ðÈ¡µÃbÁеÄÖµ
Èç¹ûaÁпªÊ¼Êý¾Ý ......