Re: ordering of 'where' sub clauses

From: Steve Heaven <steve(at)thornet(dot)co(dot)uk>
To: "Stephan Szabo" <sszabo(at)kick(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: ordering of 'where' sub clauses
Date: 2000-07-18 07:48:59
Message-ID: 3.0.1.32.20000718084859.006c56f0@mail.thornet.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

At 11:44 17/07/00 -0700, Stephan Szabo wrote:
>First off, is that query really what you want?
>main.* is probably adding an extra join with main (see the explain output --
>it appears to be doing two joins against main, one as m and one as main).
>
>Try the query as
>select m.* from main m, subset_table s where m.stockno=s.stockno and
>m.descrip ~ 'SEARCHTERM';
>
>and see what it gives you then.
>

Its different, but it still does the 'wrong' scan first and even stranger
now it doesnt do an indexed scan on subset_table:

explain select m.* from main m, subset_table s
where m.stockno=s.stockno AND m.descrip ~ 'SEARCHTERM';
NOTICE: QUERY PLAN:

Hash Join (cost=118431.88 rows=714797 width=172)
-> Seq Scan on main m (cost=79300.27 rows=714796 width=160)
-> Hash (cost=8121.17 rows=203793 width=12)
-> Seq Scan on subset_table s (cost=8121.17 rows=203793 width=12)

I'm confused !
Steve

--
thorNET - Internet Consultancy, Services & Training
Phone: 01454 854413
Fax: 01454 854412
http://www.thornet.co.uk

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Craig L. Ching 2000-07-18 14:14:38 RE: Postgresql and Postmaster response
Previous Message Denis Perchine 2000-07-18 05:12:09 Re: Quoting routines in libpq