PHP run Big Data Volume summary operation time too long webpage failure urgent URGENT!

Source: Internet
Author: User
Tags echo date
Php

The run time is about 2 hours, and the page becomes invalid. Have a friend to help you know, thank you very much.


Reply to discussion (solution)

Other languages such as C to process statistical summaries

What about the code ....


function Foreverselect () {
$db = Db::getinstance ();
Querying data based on code
$id =$_request[' id ']; Id
$datamonth =$_request[' Datamonth ']; Date
$ids =explode (', ', $id); Intercept
$jxtblist = "";
$isok = "Yes"; Control progress bar Identification
$datalist;//Return message
$datalist 1;
if (!empty ($id)) {
foreach ($ids as $key = = $li) {

$jxtbsql = "SELECT * from Jx_tbprofile where id=". $li;

$jxtblist = Query ($jxtbsql), $db

foreach ($jxtblist as $key = + $li 1) {
if ($li 1[execlevel]==0) {//0 stage
$list;
$success =0;//complete number of pens

First determine if the destination field is configured incorrectly
$strtab = "SELECT * from Jx_tbprofile_dtl where tableno= '". $li 1[tableno]. "'"; Retrieving field names
$listtab = $db->query ($strtab);
$strcol = "Show columns from". $li 1[desttable]; Get Destination table field name
$listcol = $db->query ($strcol);

$ziduan;
$boole =false;

foreach ($listtab as $keytab = + $litab) {//Configure destination table fields
foreach ($listcol as $keycol = + $licol)//Destination table field
{
if ($litab [dest_column]== $licol [' Field ']) {
$boole =true; Two names are compared to each other if they encounter the same assignment to $boole true.
echo "equal";
Break
}else{
echo $litab [Dest_column];
echo $licol [' Field '];
$boole =false;
}
}
if (! $boole) {//config table after a field corresponds to get the value of $boole if False, add the field to the $ziduan function to include the hint message
$ziduan = $ziduan. $litab [Dest_column];
$boole =false;
Break
}
}
if (! $boole) {
$datalist = $datalist. " Destination field not found ". $ziduan.", configuration Error! ";
}else{

Clear Old data
$sql =str_replace ("|datamonth|", $datamonth, $li 1[sqldeldest]);//configuration of the DELETE statement
Echo $sql;
mysql_query ($sql) or Die (Mysql_error ());
if (mysql_query ($sql)) {
echo mysql_query ($sql);
$datalist = $datalist. " The original data sheet has been cleared!
";
Query Statements $sql 1= $li 1[remarks];//Configuration
$re =str_replace ("|datamonth|", $datamonth, $sql 1); Replace character

$list 1 = query ($re), $db
mysql_query ($re) or Die (Mysql_error ());
$JX = M ($li 1[desttable]);


foreach ($list 1 as $key = $li 2)
{
$User = A ($li 1[tableno]); Instantiating an action controller object


foreach ($listtab as $key = = $litab) {
if (!empty ($litab [Mark])) {//The default field name in the destination table is mark.
echo $litab [Mark];
$_post[$litab [dest_column]]= $litab [Mark];
}else{
$_post[$litab [dest_column]]= $li 2[$litab [Source_column]];
}
}
$User->fuvalues1 ($li 2);
$tru = $jx->create ();
$bo = $jx->add ();
$success = $success +1; Number of successful strokes
}


echo Date ("Y-m-d h:i:s"). "
". $li 1[tableprofile]." Settlement complete! ". $success." Pen data.
";

$datalist = $datalist. Date ("Y-m-d h:i:s"). "
". $datamonth. $li 1[tableprofile]." Settlement complete! ". $success." Pen data.
";

}else{
$datalist = $datalist. " Delete statement out of question!
";

}

}

$this->assign (' isOK ', $isok);
}
}
}
}
}

You analyze it yourself. Which code execution is too long, can be marked out.


$list 1 = query ($re), $db
mysql_query ($re) or Die (Mysql_error ());
$JX = M ($li 1[desttable]);


foreach ($list 1 as $key = $li 2)
{
$User = A ($li 1[tableno]); Instantiating an action controller object


foreach ($listtab as $key = = $litab) {
if (!empty ($litab [Mark])) {//The default field name in the destination table is mark.
echo $litab [Mark];
$_post[$litab [dest_column]]= $litab [Mark];
}else{
$_post[$litab [dest_column]]= $li 2[$litab [Source_column]];
}
}
$User->fuvalues1 ($li 2);
$tru = $jx->create ();
$bo = $jx->add ();
$success = $success +1; Number of successful strokes
}

This is the execution of the query statement, and then inserts the result into the destination table in a single line. I configured in a separate table: source table, destination table, query statement, DELETE statement. In this code, find the configuration of this data, and then execute the query table, insert the new table operation. 4 of these data are of a large amount. I run pretty fast alone, but 4 of them run together for a long time. Know that the browser is invalid.

Post the resulting SQL to see it. The structure and index of the table are described clearly.

Set_time_limit (0);???

Post the resulting SQL to see it. The structure and index of the table are described clearly.
Jx_zy_detail_charge_belong,jx_zy_detail_charge_force,jx_zy_detail_charge to convert data between these 3 tables

This is the first query to run Sql:jx_zy_detail_charge_belong->jx_zy_detail_charge_force
SELECT Jx_zy_detail_charge_belong.data_month,
Jx_zy_detail_charge_belong.inpatient_no,
Jx_zy_detail_charge_belong.charge_date,
Jx_zy_detail_charge_belong.op_id_code,
Jx_zy_detail_charge_belong.charge_code,
Jx_zy_detail_charge_belong.charge_fee,
Jx_zy_detail_charge_belong.percentage,
Jx_zy_detail_charge_belong.ward_code,
Jx_zy_detail_charge_belong.dept_code,
Jx_zy_detail_charge_belong.order_no,
Jx_zy_detail_charge_belong.exec_unit,
Jx_zy_detail_charge_belong.retprice,
Jx_zy_detail_charge_belong.charge_amount,
Jx_zy_detail_charge_belong.serial,
Jx_zy_detail_charge_belong.group_no,
Jx_zy_detail_charge_belong.bill_code,
Jx_zy_detail_charge_belong.key_col,
Jx_zy_detail_charge_belong.pat_name
From Jx_zy_detail_charge_belong, Jx_mz_charge_item
WHERE jx_zy_detail_charge_belong.data_month = ' |datamonth| ' and
Jx_zy_detail_charge_belong.charge_code =jx_mz_charge_item.fee_code and
(Jx_mz_charge_item.exec_unit is null or
Jx_mz_charge_item.exec_unit = ")
UNION ALL
SELECT Jx_zy_detail_charge_belong.data_month,
Jx_zy_detail_charge_belong.inpatient_no,
Jx_zy_detail_charge_belong.charge_date,
Jx_zy_detail_charge_belong.op_id_code,
Jx_zy_detail_charge_belong.charge_code,
Jx_zy_detail_charge_belong.charge_fee,
Jx_zy_detail_charge_belong.percentage,
Jx_zy_detail_charge_belong.ward_code,
Jx_zy_detail_charge_belong.dept_code,
Jx_zy_detail_charge_belong.order_no,
Jx_mz_charge_item.exec_unit,
Jx_zy_detail_charge_belong.retprice,
Jx_zy_detail_charge_belong.charge_amount,
Jx_zy_detail_charge_belong.serial,
Jx_zy_detail_charge_belong.group_no,
Jx_zy_detail_charge_belong.bill_code,
Jx_zy_detail_charge_belong.key_col,
Jx_zy_detail_charge_belong.pat_name

From Jx_zy_detail_charge_belong, Jx_mz_charge_item
WHERE jx_zy_detail_charge_belong.data_month = ' |datamonth| ' and
Jx_zy_detail_charge_belong.charge_code= Jx_mz_charge_item.fee_code and
Jx_mz_charge_item.exec_unit is not null and
Jx_mz_charge_item.exec_unit <> "
is from a configuration table, Jx_mz_charge_item found in this table Charge_code and fee_code the same, find the configuration table Exec_unit meet the criteria to replace the original table with this value of the Department value

Second conversion query sql:jx_zy_detail_charge_force-"Jx_zy_detail_charge
Select Data_month,inpatient_no,charge_date,op_id_code,charge_code,charge_fee,dept_code,exec_unit,retprice, Charge_amount,serial,bill_code,pat_name
From Jx_zy_detail_charge_force
where Jx_zy_detail_charge_force.exec_unit not in (select description from Jx_code_ctl where item_no like ' ordept% ') and Da Ta_month= ' |datamonth| '
UNION ALL
Select Data_month,inpatient_no,charge_date,op_id_code,charge_code,charge_fee,dept_code,exec_unit,retprice, Charge_amount,serial,bill_code,pat_name
From Jx_zy_detail_charge_force
where Jx_zy_detail_charge_force.exec_unit in (select description from Jx_code_ctl where item_no like ' ordept% ') and not
(Jx_zy_detail_charge_force.bill_code in (select description from Jx_code_ctl where item_no like ' orbill% ') or
Jx_zy_detail_charge_force.bill_code in (select description from Jx_code_ctl where item_no like ' zlbill% ')) and Data_month = ' |datamonth| '
UNION ALL
Select Data_month,inpatient_no,charge_date,op_id_code,charge_code,charge_fee,dept_code,dept_code,retprice, Charge_amount,serial,bill_code,pat_name
From Jx_zy_detail_charge_force
where Jx_zy_detail_charge_force.exec_unit in (select description from Jx_code_ctl where item_no like ' ordept% ') and
(Jx_zy_detail_charge_force.bill_code in (select description from Jx_code_ctl where item_no like ' orbill% ') or
Jx_zy_detail_charge_force.bill_code in (select description from Jx_code_ctl where item_no like ' zlbill% ')) and Data_month = ' |datamonth| '
UNION ALL
Select Data_month,inpatient_no,charge_date,op_id_code,charge_code,charge_fee,dept_code,dept_code,retprice, Charge_amount,serial,bill_code,pat_name
From Jx_zy_detail_charge_force
Where jx_zy_detail_charge_force.exec_unit is null and data_month= ' |datamonth| '

The section exec_unit field will be executed in the section configured in table Jx_code_ctl, and the Charge large class Bill_code field also in the table jx_code_ctl the data of the large class configured in the executive department Exec_unit changed to open a single department Dept_code



Altogether divided into the outpatient and the hospitalization two sets of tables, the process is the same, here is the hospitalization procedure explanation, I run the outpatient and the hospitalization first hop SQL, then runs the outpatient service and the hospitalization second SQL, the speed probably 1 hours can run, but 4 one starts to be long, and the page also hangs off.

Background execution produces the required data, and the foreground shows the results.

Background execution produces the required data, and the foreground shows the results. Yes, that is, I put the 4 of the maximum amount of data to run together is very time-consuming, 2 2 a lot faster.

Check your SQL instructions with the EXPLAIN command and see what MySQL will give you advice

Check your SQL instructions with the EXPLAIN command and see what MySQL will give you advice

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.