RE: Working with large datasets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx] 
Sent: Monday, October 10, 2011 2:37 PM
To: Jim Giner
Cc: php-db@xxxxxxxxxxxxx
Subject: Re:  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    |                |
+--------+---------+------+-----+---------+----------------+



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux