简体   繁体   中英

Selecting (Relatively) Large Database Table

I'm using Google CloudSQL and have the following simple code:

<?php
$db = new pdo ( 'mysql:unix_socket=/cloudsql/<appid:id>;dbname=<database_name>', 'root', '' );
$db->setAttribute ( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$stmt = $db->prepare ( "SELECT column1, column2, column3, column4, column5 FROM table" );
$stmt->execute ();
$returned = $stmt->fetchAll ( PDO::FETCH_ASSOC );
echo json_encode ( $returned );
?>

But because the database table is too large (close to 150,000 lines), it seems like it's not being handled correctly. I keep getting this error message:

Error: Server Error
The server encountered an error and could not complete your request.
Please try again in 30 seconds.

I know that the problem is size because as soon as I SELECT only 3 columns instead of 5, it displays it just fine. In my opinion, 150,000 lines is not asking for too much; but it is the largest table I've created, so I don't know what I'm missing.

What should I do?

EDIT:

I've also tried to upgrade the tier from D0 (125 MB) to D1 (512 MB), but that hasn't helped either.

This warning occurs when you have exceeded your Memory Limit for your App Engine Instance Class. I am assuming you are in the Instance Class 'B1' since 150000 rows of data is exceeding that. You can change your Instance Class by setting its value in your app.yaml file. I would recommend going through this documentation to choose an Instance Class that fits your needs, anything above B1 and F1 should provide you with enough memory. Also make sure you are closing your connection by setting $db = null;

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