This is a discussion on Select * query extremely slow only for some records on small,simple table - why? within the Pgsql Performance forums, part of the PostgreSQL category; --> Hi there, I have a small, simple table of about a dozen columns, that contains less than 100 records. ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi there, I have a small, simple table of about a dozen columns, that contains less than 100 records. Primary key is a serial id, there's a few small strings, numbers and dates, and a foreign key (another serial int) Usually, a select * from tablename where owner_id = <id>; takes a negligible amount of time. However, under certain conditions/querying certain records the query takes more than 40 seconds! Those records are no different that the ones for which the query is fast. I have absolutely no idea what could cause a simple select on a small table to take that long - any pointers? Examples of things I've tried: - Select * from items where owner_id = 1; -> fast - Select * from items where owner_id = 7; -> very slow (40 seconds), owner with id of 7 is no different from others - Select * from items where owner_id = 7 and id > 0; -> dummy conditions makes it fast again, but I 'm using an O/R- framework, so i can't add the dummy condition manually It happens only on the production server, on a similar testing server as well as my local development machine it works fine. Postgres version on the production machine is 8.1.9 running on CentOS linux. |