![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, we have several postgres sql 8.x machines here with about 4500 tables on each. Each table has about 150000 up to 5000000 rows. We saw, that a select count(*) on some tables takes about 120 secs. Other tables with same amount |
|
of date answers within 50 msecs. there is an index on each table for a timestamp row. We thought, the index is corrupt and dropped them. We create the index new - same problem with count(*). |
|
The problem is not related to the count of rows for that specific table. Second try was to dump table, drop table and play back the dump. Now the count is delivvered within millisecs. |
#3
| |||
| |||
|
|
begin peter stimpel schrieb: Hi, we have several postgres sql 8.x machines here with about 4500 tables on each. Each table has about 150000 up to 5000000 rows. We saw, that a select count(*) on some tables takes about 120 secs. Other tables with same amount Because of MVCC, a count(*) implies a full table scan. of date answers within 50 msecs. there is an index on each table for a timestamp row. We thought, the index is corrupt and dropped them. We create the index new - same problem with count(*). An index can't help in tis case. |
|
The problem is not related to the count of rows for that specific table. Second try was to dump table, drop table and play back the dump. Now the count is delivvered within millisecs. You have found the problem! You table contains many dead rows, you should regulary do a vacuum. |
#4
| |||
| |||
|
|
of date answers within 50 msecs. there is an index on each table for a timestamp row. We thought, the index is corrupt and dropped them. We create the index new - same problem with count(*). An index can't help in tis case. Is that the case with Postgres? Theoretically (and also practically for other DB products) a full index scan can help indeed because the index has typically less leaf pages hence less IO. |
|
You have found the problem! You table contains many dead rows, you should regulary do a vacuum. That's interesting news. On one of those days I have to read Postgres docs about how the storage engine works. |
#5
| |||
| |||
|
|
The problem is not related to the count of rows for that specific table. Second try was to dump table, drop table and play back the dump. Now the count is delivvered within millisecs. You have found the problem! You table contains many dead rows, you should regulary do a vacuum. |
#6
| |||
| |||
|
|
begin Robert Klemme schrieb: of date answers within 50 msecs. there is an index on each table for a timestamp row. We thought, the index is corrupt and dropped them. We create the index new - same problem with count(*). An index can't help in tis case. Is that the case with Postgres? Theoretically (and also practically for other DB products) a full index scan can help indeed because the index has typically less leaf pages hence less IO. There are other solutions for PG, for instance, you can ask the information_schema, but for this you need actual statistics. |
|
You have found the problem! You table contains many dead rows, you should regulary do a vacuum. That's interesting news. On one of those days I have to read Postgres docs about how the storage engine works. Deleted rows are marked as deleted, but not realy deleted. VACUUM¹ does this. And yes: an update create also a dead row. |
#7
| |||
| |||
|
|
Second try was to dump table, drop table and play back the dump. Now the count is delivvered within millisecs. You have found the problem! You table contains many dead rows, you should regulary do a vacuum. But I do a "vacuum analyze;" each night. So that shouldnt be the source of the probhlem, I think. |
![]() |
| Thread Tools | |
| Display Modes | |
| |