Re: "AND", "OR" and Materialize :((((

From: Meszaros Attila <tilla(at)draconis(dot)elte(dot)hu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: "AND", "OR" and Materialize :((((
Date: 2001-08-26 18:09:59
Message-ID: Pine.LNX.4.21.0108261940370.26952-100000@draconis.csoma.elte.hu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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't felt this in the result)

Unfortunatelly the cost prediction in line 2 may be close to
the real cost. According to some measures:
time for the query with '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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message markir 2001-08-26 22:49:26 Re: Different Choices For Index/Sequential Scan With And Without A Join In 7.2
Previous Message Tom Lane 2001-08-26 15:51:23 Re: "AND", "OR" and Materialize :((((