From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | David Blasby <dblasby(at)refractions(dot)net> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: SELECT * FROM <table> LIMIT 1; is really slow |
Date: | 2004-05-26 22:17:55 |
Message-ID: | 2940.1085609875@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
David Blasby <dblasby(at)refractions(dot)net> writes:
> I have a table with about 16,000,000 rows in it.
> When I do a:
> SELECT * FROM <table> LIMIT 1;
> it takes about 10 minutes (thats about how long it takes to do a full
> sequential scan).
The only explanation that comes to mind is huge amounts of dead space
before the first live row. But the output of "vacuum verbose" would
probably be enough to tell whether this is really the correct diagnosis.
> I had originally thought that there might be a large number of
> "wasted/retired" tuples in the table so I "vacuum analysed" the
> database. It had no effect.
It wouldn't; you'd need vacuum full to collapse out the dead space.
You could also try CLUSTER which is faster than VACUUM FULL when most
of the data has to be moved anyway. (Some days I think we should dump
VACUUM FULL, because it's optimized for a case that's no longer very
interesting...)
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2004-05-26 22:28:25 | Re: SELECT * FROM <table> LIMIT 1; is really slow |
Previous Message | Alvaro Herrera | 2004-05-26 22:03:41 | Nested xacts: looking for testers and review |