Re: "AND", "OR" and Materialize :(((( - Mailing list pgsql-sql

From Meszaros Attila
Subject Re: "AND", "OR" and Materialize :((((
Date
Msg-id Pine.LNX.4.21.0108261940370.26952-100000@draconis.csoma.elte.hu
Whole thread Raw
In response to Re: "AND", "OR" and Materialize :((((  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
Hi,

> > WHY SHALL IT MATERIALIZE A CONSTANT RESULT IN A LOOP OF 120000 TIMES ??
> > [it would be enough to materialize only once,
> 
> Which in fact is exactly what the materialize node is for.  The reported
> costs are pretty bogus, but AFAICT the plan is the right thing.
Thanx for the answer.I've thought the same (eg. materialize should reduce the amount    of work to be done, but I
haven'tfelt this in the result)
 
Unfortunatelly the cost prediction in line 2 may be close tothe real cost. According to some measures:    time for the
querywith 'AND':      2 sec    time for the query with 'OR':    421 sec
 
So the question is what to do? Can I speed up the second one?
[vacuum analyze and indices are done, postgres version is 7.1.2]

1:Aggregate  (cost=5017202.06..5017202.06 rows=1 width=24)
2:  ->  Nested Loop  (cost=0.00..5016900.05 rows=120806 width=24)
3:        ->  Seq Scan on _108  (cost=0.00..44.70 rows=1670 width=8)
4:        ->  Materialize  (cost=2097.79..2097.79 rows=60421 width=16)
5:              ->  Nested Loop  (cost=0.00..2097.79 rows=60421 width=16)
6:                    ->  Seq Scan on _110  (cost=0.00..1.37 rows=37 width=8)
7:                    ->  Seq Scan on _111  (cost=0.00..40.33 rows=1633 width=8)

Attila



pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: "AND", "OR" and Materialize :((((
Next
From:
Date:
Subject: Re: Different Choices For Index/Sequential Scan With And Without A Join In 7.2