我有一个数据库问题,当它很大时。我将描述:它非常简单 - 由第三方应用程序创建,并且在一个表中只有字段:“页面”和“数据” - 关于页面(网址)和数据。 所以它在低页数~5000的情况下工作得很完美,但它在100k页面上有误。当我打开网站上的索引页面或第二页,第3页 - 它打开正确,但如果我打开55321页面 - 我有404错误。
我的配置快速为100к-pages db:vps与ssdaтвnginx+ php + fpm就可以了。内存没问题,cpu还可以。
1。导入后可能是索引,我必须等待它吗?
2. 或者我可能需要手动创建索引吗?任何人都可以帮助指挥。
3. 我的数据库以此开头:
CREATE TABLE `domain_com` (
`page` varchar(200) NOT NULL,
`data` text,
PRIMARY KEY (`page`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
可能需要切换到MYISAM Engine来改进索引吗?
====从示例页面添加了一个代码(在我的情况下是product.php)====
<?
$n = $_GET["n"];
if (isset($_GET["ctgfolder"])) {
$ctgfolder = $_GET["ctgfolder"];
} else {
$ctgfolder = '';
}
if (strlen($ctgfolder) > 0) {
$fn = "$ctgfolder/product-$n.txt";
} else {
$fn = "product-$n.txt";
}
if (file_exists($fn) == true) {
$file = fopen($fn, 'r');
$tx = fread($file, filesize($fn));
fclose($file);
} else {
if (file_exists("dbinfo.php") == true) {
include "dbinfo.php";
$site_encoding = 'utf8';
$msconnect = mysql_connect($mshost, $msuser, $mspassword);
mysql_select_db($msname, $msconnect);
mysql_query("SET NAMES 'utf8'");
if ($site_encoding != 'utf8') {
mysql_query("SET character_set_client = $site_encoding");
mysql_query("SET character_set_connection = $site_encoding");
mysql_query("SET character_set_results = $site_encoding");
}
$res = mysql_query("SELECT * FROM `domain_com` WHERE page='$fn'");
if ($res) {
if ($row = mysql_fetch_array($res)) {
$tx = $row['data'];
$file = fopen($fn, 'w');
fwrite($file, $tx);
fclose($file);
}
}
mysql_close($msconnect);
}
}
$k = 0;
$p = strpos($tx, '{#');
while ($p !== false) {
$p2 = strpos($tx, '#}', $p);
$im = substr($tx, $p + 2, $p2 - ($p + 2));
$k++;
//--------------
if (file_exists("dmcr.php")) {
include "dmcr.php";
} else {
include "../dmcr.php";
}
//-------------
$mcr[$k] = $im;
$p = strpos($tx, '{#', $p2 + 2);
}
if (file_exists("template_page.php")) {
include "template_page.php";
} else {
include "../template_page.php";
}
?>
====这是index.php ======
$fn="index_page.txt";
if(file_exists($fn)==true){
$file=fopen($fn,'r');
$tx=fread($file,filesize($fn));
fclose($file);
} else {
if(file_exists("dbinfo.php")==true){
include "dbinfo.php";
$site_encoding='utf8';
$msconnect = mysql_connect($mshost, $msuser, $mspassword);
mysql_select_db($msname, $msconnect);
mysql_query("SET NAMES 'utf8'");
if($site_encoding!='utf8'){
mysql_query("SET character_set_client = $site_encoding");
mysql_query("SET character_set_connection = $site_encoding");
mysql_query("SET character_set_results = $site_encoding");
}
$res=mysql_query("SELECT * FROM `domain_com` WHERE page='$fn'");
if($res){
if($row=mysql_fetch_array($res)){
$tx=$row['data'];
$file=fopen($fn,'w');
fwrite($file,$tx);
fclose($file);
}
}
mysql_close($msconnect);
}
}
$k=0;
$p=strpos($tx,'{#');
while($p!==false){
$p2=strpos($tx,'#}',$p);
$im=substr($tx,$p+2,$p2-($p+2));
$k++;
//--------------
include "dmcr.php";
//-------------
$mcr[$k]=$im;
$p=strpos($tx,'{#',$p2+2);
}
include "template_page.php";
?>
=== ctg.php =====
<?
$c = $_GET["c"];
$p = $_GET["p"];
if (strlen($c) == 0) {
$c = 1;
}
if (strlen($p) == 0 or is_numeric($p) == false) {
$p = 1;
}
$fn = "ctg-$c-$p.txt";
if (file_exists($fn) == true) {
$file = fopen($fn, 'r');
$tx = fread($file, filesize($fn));
fclose($file);
} else {
if (file_exists("dbinfo.php") == true) {
include "dbinfo.php";
$site_encoding = 'utf8';
$msconnect = mysql_connect($mshost, $msuser, $mspassword);
mysql_select_db($msname, $msconnect);
mysql_query("SET NAMES 'utf8'");
if ($site_encoding != 'utf8') {
mysql_query("SET character_set_client = $site_encoding");
mysql_query("SET character_set_connection = $site_encoding");
mysql_query("SET character_set_results = $site_encoding");
}
$res = mysql_query("SELECT * FROM `domain_com` WHERE page='$fn'");
if ($res) {
if ($row = mysql_fetch_array($res)) {
$tx = $row['data'];
$file = fopen($fn, 'w');
fwrite($file, $tx);
fclose($file);
}
}
mysql_close($msconnect);
}
}
$k = 0;
$p = strpos($tx, '{#');
while ($p !== false) {
$p2 = strpos($tx, '#}', $p);
$im = substr($tx, $p + 2, $p2 - ($p + 2));
$k++;
//--------------
if (file_exists("dmcr.php")) {
include "dmcr.php";
} else {
include "../dmcr.php";
}
//-------------
$mcr[$k] = $im;
$p = strpos($tx, '{#', $p2 + 2);
}
include "template_page.php";
?>
===在模板页面中,我们有一个包含=====
的template.php