Re: [PERFORM] An "obvious" index not being used

2008-07-20 Thread Daniele Varrazzo
Tom Lane ha scritto: Daniele Varrazzo <[EMAIL PROTECTED]> writes: In my problem I had 2 tables: a small one (accounts), a large one (foo). The way the query is written doesn't allow the stats from the large table to be used at all, unless the records from the small table are fetched. This is i

Re: [PERFORM] An "obvious" index not being used

2008-07-19 Thread Tom Lane
Daniele Varrazzo <[EMAIL PROTECTED]> writes: > In my problem I had 2 tables: a small one (accounts), a large one (foo). The > way the query is written doesn't allow the stats from the large table to be > used at all, unless the records from the small table are fetched. This is > independent from

Re: [PERFORM] An "obvious" index not being used

2008-07-19 Thread Daniele Varrazzo
Francisco Reyes writes: Daniele Varrazzo writes: I suspect the foo.account_id statistical data are not used at all in query: the query planner can only estimate the number of accounts to look for, not You mentioned you bumped your default_statistics_target. What did you increase it to? My d

Re: [PERFORM] An "obvious" index not being used

2008-07-18 Thread Francisco Reyes
Daniele Varrazzo writes: I suspect the foo.account_id statistical data are not used at all in query: the query planner can only estimate the number of accounts to look for, not You mentioned you bumped your default_statistics_target. What did you increase it to? My data sets are so "strange"

Re: [PERFORM] An "obvious" index not being used

2008-06-19 Thread Daniele Varrazzo
Daniele Varrazzo <[EMAIL PROTECTED]> wrote: > >> select count(*) from foo >> where foo.account_id in ( >> select id from accounts where system = 'abc'); > >> Total runtime: 13412.226 ms > > Out of curiosity, how does it do with the logically equivalent?: > > select count(

Re: [PERFORM] An "obvious" index not being used

2008-06-19 Thread Kevin Grittner
>>> Daniele Varrazzo <[EMAIL PROTECTED]> wrote: > select count(*) from foo > where foo.account_id in ( > select id from accounts where system = 'abc'); > Total runtime: 13412.226 ms Out of curiosity, how does it do with the logically equivalent?: select count(*) from f

Re: [PERFORM] An "obvious" index not being used

2008-06-18 Thread Daniele Varrazzo
Tom Lane ha scritto: Daniele Varrazzo <[EMAIL PROTECTED]> writes: There is an index in the field "foo.account_id" but is not used. The resulting query plan is: Aggregate (cost=300940.70..300940.71 rows=1 width=0) (actual time=13412.088..13412.089 rows=1 loops=1) -> Hash IN Join (cost

Re: [PERFORM] An "obvious" index not being used

2008-06-18 Thread Tom Lane
Daniele Varrazzo <[EMAIL PROTECTED]> writes: > There is an index in the field "foo.account_id" but is not used. The > resulting > query plan is: > Aggregate (cost=300940.70..300940.71 rows=1 width=0) (actual > time=13412.088..13412.089 rows=1 loops=1) > -> Hash IN Join (cost=11.97..2998

[PERFORM] An "obvious" index not being used

2008-06-18 Thread Daniele Varrazzo
Hello, I am experiencing a query for which an useful index is not being used by PostgreSQL. The query is in the form: select count(*) from foo where foo.account_id in ( select id from accounts where system = 'abc'); and the size of the tables it works on is: - 270 records i