简体   繁体   中英

How to fix page error 500 when SQL query takes too long?

I recently upgraded my cloud instance from Ubuntu 14 to 16. It's a Laravel application, there's a page which reads about 200000 entries from a table with 3 columns and writes them to a CSV file. The query involves 2 where clauses- status=0 and CHAR_LENGTH()=7 .This is the query-

select code from code where status=0 and CHAR_LENGTH(code)=7 limit 200000;

There are more than 30 million entries in that code table.

The page had been working before upgrading to Ubuntu 16, but now the page gives Error 500 after being stuck on the page for about 1-2 minutes. Note that the page works if I try to read lower number of entries eg 20 entries and the file also gets written.

Can anyone please help me with this it's a critical operation for our website.

I just figured out the problem, after the upgrade the PHP5 folder was deleted and PHP 7 was installed. Previously in php5/fpm/php.ini file the max_execution_time and memory_limit was set to 600 and 2GB respectively. But after the upgrade in php/7/fpm/php.ini file the default values for max_execution_time and memory_limit was set to 60 and 300MB respectively. I changed the values to 600 and 2GB and now the system is working perfectly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM