RE: [PHP-DB] Working with large datasets
| From: | Toby Hart Dyke | Date: | Mon, 10 Oct 2011 21:02:03 +0000 |
| Subject: | RE: [PHP-DB] Working with large datasets | ||
| References: | 1 2 3 4 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-48024@lists.php.net to get a copy of this message | ||
You have a field in your WHERE clause that isn't indexed - you need an
index. Try something like this:
ALTER TABLE
Database.Table ADD INDEX
state(state);
Think about it - you're asking for the rows that have a certain value in
the 'state' field. If you don't provide the database with an index, it has
to do a full table scan to retrieve the results.
Toby
-----Original Message-----
From: Jason Pruim [mailto:pruimj@gmail.com]
Sent: Monday, October 10, 2011 2:37 PM
To: Jim Giner
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] Working with large datasets
RIght now though I only have 1 state inputed to work with though. I may need
to just increase the max execution time as well... But it still runs too
slowly ... Even from the commandline searching for a simple: SELECT * from
Table WHERE state="test"; takes 56.96 seconds to search and returns only 2
records with 4 columns... Could this just be a hardware problem?
Here is the structure of the table Im working with:
+--------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+---------+------+-----+---------+----------------+
| ID | int(11)| NO | PRI | NULL | auto_increment |
| phone| text | NO | MUL | NULL | |
| config | text | NO | | NULL | |
| state | text | YES | | NULL | |
+--------+---------+------+-----+---------+----------------+