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