Gentoo Archives: gentoo-server

From: "Dice R. Random" <dicerandom@×××××.com>
To: gentoo-server@l.g.o
Subject: [gentoo-server] MySQL slow running selects on tables that *used* to be large
Date: Wed, 14 Jun 2006 19:51:01
Message-Id: d9b9989b0606141244o65602c19tfddb82cfba7055e3@mail.gmail.com
1 Hello list,
2
3 I have a fairly low end server (dual P3 450s, 768 megs of RAM) which
4 I'm running MySQL on. The database is primarily used for logging
5 purposes and so it has a continually growing number of records. I do
6 try to keep the number of records down by moving data off to an
7 archive table periodically.
8
9 Last night I noticed that selects on the logging table were taking
10 over a second to execute, sure enough the database was starting to get
11 a little big (~250000 entries). I moved most of the data out to the
12 archive table:
13
14 INSERT INTO archive SELECT * FROM logs WHERE
15 timestamp<'some-time-about-an-hour-ago';
16 DELETE FROM logs WHERE timestamp<'some-time-about-an-hour-ago';
17
18 This left about 350 rows in the logs table and a quarter million more
19 in the archive. The problem is that even with only 350 rows currently
20 in the table selects were still taking over a second to execute. When
21 I first created this table I could run selects against it with a few
22 thousand rows and still keep in the hundredth of a second range.
23
24 Shouldn't 350 entries be 350 entries? Why should it take longer to do
25 a select against a table which used to have a large number of entries
26 in it?
27
28 I'm using dev-db/mysql-4.0.25-r2 by the way.
29
30 Thanks for any help.
31 --
32 gentoo-server@g.o mailing list

Replies