Quantcast
Channel: linuxadmin: Expanding Linux SysAdmin knowledge
Viewing all articles
Browse latest Browse all 17788

Gotta love MySQL indexing

$
0
0

On a LAMP box, a customer had a database where basically whenever a new IP visits the site, the page checks and potentially adds/updates to that table. Every single query was taking from 2-5 seconds to complete, as this thing has 4.5 million rows in it.

Checked for indexes (SHOW INDEXES FROM tablename), saw they had none at all, so I added indexes for the typical fields in the "WHERE" portion of the SELECT query.

Queries went down from 4s to 0.01s. The only worry now is that UPDATEs will slow down a bit due to having to update that index everytime, but that's much less frequent than the SELECT's they were doing.

submitted by deviantryan
[link] [4 comments]

Viewing all articles
Browse latest Browse all 17788

Trending Articles