Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Performance > Re: Optimizer's...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 6 Topic 4015 of 4424
Post > Topic >>

Re: Optimizer's issue

by arhipov@[EMAIL PROTECTED] (Vlad Arkhipov) Apr 28, 2008 at 10:51 AM

PFC пишет:
> On Thu, 24 Apr 2008 03:14:54 +0200, Vlad Arkhipov 
> <arhipov@[EMAIL PROTECTED]
> wrote:
>
>> I found strange issue in very simple query. Statistics for all columns
>> is on the level 1000 but I also tried other levels.
>>
>> create table g (
>>   id bigint primary key,
>>   isgroup boolean not null);
>>
>> create table a (
>>   groupid bigint references g(id),
>>   id bigint,
>>   unique(id, groupid));
>>
>> analyze g;
>> analyze a;
>>
>> select count(*) from a
>> 294
>>
>> select count(*) from g
>> 320
>>
>> explain analyze
>> select *
>> from g
>>   join a on a.groupid = g.id
>> where g.isgroup
>>
>> Hash Join  (cost=5.35..11.50 rows=11 width=25) (actual
time=0.261..1.755
>> rows=294 loops=1)
>>   Hash Cond: (a.groupid = g.id)
>>   ->  Seq Scan on a  (cost=0.00..4.94 rows=294 width=16) (actual
>> time=0.047..0.482 rows=294 loops=1)
>>   ->  Hash  (cost=5.20..5.20 rows=12 width=9) (actual time=0.164..0.164
>> rows=12 loops=1)
>>         ->  Seq Scan on g  (cost=0.00..5.20 rows=12 width=9) (actual
>> time=0.042..0.136 rows=12 loops=1)
>>               Filter: isgroup
>> Total runtime: 2.225 ms
>
>     You should really put an EXPLAIN ANALYZE of your big query.
>
>     This little query plan seems OK to me.
>     Two very small tables, ok, hash'em, it's the best.
>     Now, of course if it is repeated for every row in your JOIN, you 
> have a problem.
>     The question is, why is it repeated for every row ?
>     This cannot be answered without seeing the whole query.
>
>     Another question would be, is there a way to structure the tables 
> differently ?
>     Again, this cannot be answered without seeing the whole query, and 
> some explanation about what the data & fields mean.
>
>     Please provide more information...
>
>
>
I redesigned tables structure and the query seems to be become faster. 
You was right, the problem was not in this query.


-- 
Sent via pgsql-performance mailing list (pgsql-performance@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
 




 6 Posts in Topic:
Optimizer's issue
arhipov@[EMAIL PROTECTED]  2008-04-24 10:14:54 
Re: Optimizer's issue
laurenz.albe@[EMAIL PROTE  2008-04-24 10:47:32 
Re: Optimizer's issue
arhipov@[EMAIL PROTECTED]  2008-04-24 18:47:37 
Re: Optimizer's issue
matthew@[EMAIL PROTECTED]  2008-04-24 11:50:24 
Re: Optimizer's issue
lists@[EMAIL PROTECTED]   2008-04-24 18:24:50 
Re: Optimizer's issue
arhipov@[EMAIL PROTECTED]  2008-04-28 10:51:38 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 8:17:35 CST 2008.