½ÃÀÛÆäÀÌÁö·Î Áñ°Üã±âÃß°¡
·Î±×ÀÎ
ȸ¿ø°¡ÀÔ l Ã⼮üũ l ¸¶ÀÌÆäÀÌÁö l CGIMALL
ÀÚ·á½Ç »çÀÌÆ®µî·Ï ·©Å·100 ÇÁ·Î±×·¥¸®ºä °ü¸®ÀÚÃßõÀÚ·á Ãʺ¸°¡À̵å
Ä¿¹Â´ÏƼ
Àüü ÆîÃ帱â
Äü¸Þ´º¸µÅ© jquery , CSS , PHP , Javascript , ¹«·áÆùÆ® , ASP
»ó¼¼°Ë»ö
Ȩ > Ä¿¹Â´ÏƼ > Áú¹®°ú´äº¯ »ó¼¼º¸±â
Ä¿¹Â´ÏƼ ±¸Àα¸Á÷
»çÀÌÆ®µî·Ï
Ŭ¶ó¿ìµåű×
Javascript
PHP
ASP
CSS
html
mysql
jquery
image
Mobile
API
slide
°Ô½ÃÆÇ
¸Þ´º
ÇöÀçÁ¢¼ÓÀÚ ¸í »õ·Î°íħ
°Ô½ÃÆÇŸÀÌƲ Áú¹®°ú´äº¯ / »ó¼¼º¸±â
Æ®À§ÅÍ·Î º¸³»±â
Ãßõ¼ö 65 | Á¶È¸¼ö 848 | µî·ÏÀÏ 2001-04-05 20:37:02

´Ð³×ÀÓ

HappyCGI

À̸ÞÀÏ

hero@happycgi.com

Á¦¸ñ

[ÆÁ] ÆäÀÌÁö ÂÉ°³±â ¼Óµµ Çâ»ó (limit°ü·Ã)
³»¿ë
phpschool¿¡¼­ ¹ßÃéµÈ ±ÛÀÔ´Ï´Ù. ( http://www.phpschool.com )

cassatt@hanmir.com



¾È³çÇϼ¼¿ä.

¿ä»õ php¸¦ °øºÎÇÏ°í Àִµ¥¿ä,

¿©±â ±ÛÀ» º¸´Ï, ÆäÀÌ¡À» À§ÇØ º¸Åë select ¹®ÀÇ limit¸¦ ¾²´Â °Í °°´õ±º¿ä. ±×·±µ¥ limit°¡.... Á» ÀÌ»óÇÕ´Ï´Ù. '¼Óµµ Çâ»ó'À̶ó Á¦¸ñÀ» ºÙÀ̱ä Çߴµ¥, ±×º¸´Ù limit ÀÇ °á°ú°¡ ÀÌ»óÇÏ°í Çؼ­, ´Ù¸¥ ºÐ ¾î¶»°Ô ÇÏ´ÂÁö ±Ã±ÝÇؼ­ ¾¹´Ï´Ù.

¿ì¼± db´Â mysqlÀÌ°í,
Å×ÀÌºí¿¡´Â 20¸¸°³ÀÇ ±ÛÀÌ µé¾î°¡ ÀÖ°í, °Ô½ÃÆÇ¿ë Å×À̺íÀÔ´Ï´Ù. Å×À̺í Å©±â´Â 100M°¡ ³Ñ´Â, Á» Å« Å×À̺íÀÔ´Ï´Ù. ( ±Û ³»¿ëÀº ¼º°æ 1ÀýÀ» 10¹ø ¹Ýº¹)
´äº¯Çü °Ô½ÃÆÇÀε¥, ¸ñ·Ï º¸¿©ÁÙ¶§ int Çü ÇÑÇʵ常 ±âÁØÇؼ­ Á¤·ÄµÇµµ·Ï µÇ¾î ÀÖ½À´Ï´Ù. ±× Çʵå À̸§Àº thread ÀÔ´Ï´Ù. thread Çʵå´Â primary key·Î À妽ºµË´Ï´Ù.
PC´Â PIII 800MHz, win2k¿¡ mysqlÀ» ±ò¾Ò½À´Ï´Ù. php´Â iis¿¡¼­ µ¹¸³´Ï´Ù.

±×·±µ¥, limit °¡ Á» ÀÌ»óÇÕ´Ï´Ù.

Äõ¸®1. select num,thread from board order by thread desc limit 200000,20
ÀÌ·± Äõ¸®¹®ÀÌ 33ÃÊ°¡ °É¸³´Ï´Ù. ( numÀº intÇüÀÔ´Ï´Ù )

Äõ¸®2. select thread from board order by thread desc limit 200000,20
ÀÌ°Ç 0.18 ÃÊ¸é µË´Ï´Ù. ... ÀÌ»óÇÏÁö ¾Ê½À´Ï±î?

ÇÑÆí
Äõ¸®3. select thread from board where thread>0 order by thread desc limit 200000,20
ÀÌ°Ç °á±¹ °°Àº Äõ¸®ÀÓ¿¡µµ ( thread´Â Ç×»ó ¾ç¼öÀÓ ) 44ÃÊ°¡ °É¸³´Ï´Ù.

limit°¡ µé¾î°¥¶§, mysqlÀÌ Á» ¸ÛûÇØ(?) Áö´Â °Í °°¾Æ¿ä. Äõ¸® 1ÀÌ ±×·¸°Ô ´À¸®´Ù¸é, ¾ÖÃÊ¿¡ 2·Î thread¸¸ ±¸Çؼ­, ±× thread¿¡ ÇØ´çÇÏ´Â num °ª¸¸ ãÀ¸¸é ÈξÀ ºü¸¦ °Í °°Àºµ¥,... ±×·¸°Ô ¾ÈÇϳª º¾´Ï´Ù.

¶Ç ÀÌ»óÇÑ°Ç,

select thread from board where thread<200000 order by thread desc limit 20
ÀÌ°Ç 0.06ÃÊ¸é µÇ´Âµ¥,
select thread,num from board where thread<200000 order by thread desc limit 20
ÀÌ°Ç 20ÃÊ°¡ °É¸°´Ù´Â °Ì´Ï´Ù. ( ÇÑÆí
select thread,num from board where thread between 200000 and 200020 order by thread desc ÀÌ°Ç À妽º°¡ Á¦´ë·Î ¸Ô¾î¼­ 0.00 ÃÊ ´ëÀÔ´Ï´Ù )

Äõ¸®2°¡ ¿Ö ±×·¸°Ô ºü¸¥Áö, Á¤È®È÷ ¸ð¸£°Ú½À´Ï´Ù. select ¹® Àüü¿¡ Çʵ尡 Çϳª¸¸ ¾²À̸é, Å×À̺í·Î °¡Áö ¾Ê°í À妽º¿¡¼­¸¸ ÇØ°áÇصµ µÇ¾î¼­ ±×·¸Áö ¾ÊÀ»±î ÇÏ´Â »ý°¢ÀÌ µì´Ï´Ù. Àü¿¡ ¾îµð¼±°¡ º» covered-query °°Àº °Í ¾Æ´Ò±î ÇÏ´Â »ý°¢ÀÌ µå³×¿ä.

¾ÏÆ°, ±×·¡¼­ ³»¸° °á·ÐÀ¸·Î, ÆäÀÌ¡À» ´ë·« ´ÙÀ½Ã³·³ ÇÏ¸é ºü¸£Áö ¾ÊÀ»±î ÇÏ´Â °Ì´Ï´Ù. ( ¿¡·¯ 󸮴 »®´Ï´Ù. )

$pagesize=20; # ÆäÀÌÁö´ç ±Û¼ö
$p = ÆäÀÌÁö¹øÈ£;
$pstart = $p*$pagesize;

$conn = mysql_connect("localhost","xxx","xxx");
$res= mysql_select_db("xxx");
$sql = "select thread from board order by thread desc limit $pstart,$pagesize";

$rs = mysql_query( $sql, $conn);

$num_row=mysql_affected_rows( $conn );

$row=mysql_fetch_row($rs);

$thread_end=$row[0];
mysql_data_seek($rs, $num_row-1);
$row=mysql_fetch_row($rs);
$thread_start=$row[0];

$sql = "select thread,title,email,uname,refer,idate from board where thread between $thread_start and $thread_end order by thread desc";
$rs = mysql_query(  $sql, $conn);
#... ÀÌÇÏ $rs·Î ÀÛ¾÷

½ÇÁ¦·Î Çغ¸´Ï±î, 20¸¸°Ç¿¡¼­ ¸¶Áö¸· ÆäÀÌÁö °¡´Â °ÍÀÌ 0.5ÃÊ°¡ ¾È°É¸®´õ±º¿ä. ( ¿ø·¡´ë·Î Çϸé timeout¿¡ °É¸³´Ï´Ù )


Ãßõ½ºÅ©·¦¼Ò½ºº¸±â ¸ñ·Ï
ÀÌÀü°Ô½Ã±Û ÅؽºÆ® ÆÄÀÏ sql¿¡ ³Ö±â 2001-04-05 17:12:02
´ÙÀ½°Ô½Ã±Û ±âÁ¸ÀÇ Å×ÀÌºí¿¡ ÀÎÅؽº Å° Ãß°¡Çϱâ 2001-04-05 21:26:05