Re: [HACKERS] Efficiency again...

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: miker(at)scifair(dot)acadiau(dot)ca (Michael Richards)
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Efficiency again...
Date: 1998-07-23 00:40:58
Message-ID: 199807230040.UAA06813@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Now here is the plan I expect for a single test1 value
> searchengine=> explain select * from test where test1=1;
> Index Scan on test (cost=0.00 size=0 width=8)
>
> But look:
> searchengine=> explain select * from test where test1=1 or test1=2;
> Seq Scan on test (cost=0.00 size=0 width=8)
>
> ugh! Sequential. This may be OK for a small database, but in my
> application I have many rows:
> searchengine=> explain select * from word_detail where word_id=23423 or
> word_id=68548;
>
> Seq Scan on word_detail (cost=205938.73 size=510342 width=10)
>
> That costs a _LOT_.
>
> Wouldn't it be better to do n sequential scans where n is the number of
> or'd together values? Using IN doesn't help out either...
>
> searchengine=> explain select * from test where test1 IN (5,9);
> Seq Scan on test (cost=0.00 size=0 width=8)
>
> Sometimes I wish I had the power to tell the DBMS how I wanted a query
> done...

Yep, it is on our TODO list, and we have someone trying some fix for
6.4. It has to do the conjunctive normal form(cnf).

--
Bruce Momjian | 830 Blythe Avenue
maillist(at)candle(dot)pha(dot)pa(dot)us | Drexel Hill, Pennsylvania 19026
+ If your life is a hard drive, | (610) 353-9879(w)
+ Christ can be your backup. | (610) 853-3000(h)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Brett McCormick 1998-07-23 02:05:45 subselects & views
Previous Message Michael Richards 1998-07-22 23:17:33 Efficiency again...