![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
It would be very nice, if someone could have a look at the query I'm trying to optimize. At the moment, I don't understand PostgreSQL's behaviour and are stuck. Thanks a lot in advance. |
#3
| |||
| |||
|
|
Martin Hampl <Martin.Hampl (AT) gmx (DOT) de> writes: It would be very nice, if someone could have a look at the query I'm trying to optimize. At the moment, I don't understand PostgreSQL's behaviour and are stuck. Thanks a lot in advance. Did you ANALYZE these tables? |
|
Also, please post EXPLAIN ANALYZE not just EXPLAIN when complaining about bad plans. Since the essence of your complaint is that the planner's estimates are wrong, showing us only estimates and not reality makes it hard to give constructive suggestions ... |
#4
| |||
| |||
|
|
Am 30.04.2004 um 01:32 schrieb Tom Lane: Did you ANALYZE these tables? I did. |
|
-> Index Scan using s_pkey on s (cost=0.00..24698.44 rows=3367 width=16) (actual time=75.933..589743.642 rows=1111220 loops=1) |
|
Maybe that *is* what i wanted it to do? However, searching just for 'FACTSHEET' is very quick (I rebooted before this query to clear any cache---is there a better way to do this?): and I would have thought that the results of this query could have been used to search for the respective records in s (using on of the indexes)? |
#5
| |||
| |||
|
|
It could be that this table has a lot of empty pages near the front, which is a condition that's known to lead to underestimated row count from ANALYZE. (Manfred is working on a better ANALYZE sampling method that should avoid such errors in future.) Try doing a straight VACUUM and see if the row count estimate gets better. |
#6
| |||
| |||
|
|
Am 30.04.2004 um 17:52 schrieb Tom Lane: It could be that this table has a lot of empty pages near the front, I never deleted anything from this database, but it might be that I dropped some of the tables a couple of times when populating the database. Also 'copy from' failed a couple of times. Can that have the same effect? |
#7
| |||
| |||
|
|
Martin Hampl <Martin.Hampl (AT) gmx (DOT) de> writes: Am 30.04.2004 um 17:52 schrieb Tom Lane: It could be that this table has a lot of empty pages near the front, I never deleted anything from this database, but it might be that I dropped some of the tables a couple of times when populating the database. Also 'copy from' failed a couple of times. Can that have the same effect? A failed copy-in would leave a dead row for each input line that it was able to process before hitting the error. So potentially that could account for a lot of dead rows. I think there is a hint on the COPY reference page suggesting that you VACUUM in such a situation ... |
#8
| |||
| |||
|
#9
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |