Re: Fetching multiple rows in single round trip

From: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Fetching multiple rows in single round trip
Date: 2012-05-19 12:30:02
Message-ID: jp83oa$g73$1@reversiblemaps.ath.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2012-05-18, Jon Smark <jon(dot)smark(at)yahoo(dot)com> wrote:

> I can think of two solutions:
>
> 1) "SELECT wid, data FROM widgets WHERE wid IN $targets"
> 2) "SELECT wid, data FROM widgets WHERE ARRAY [wid] <@ $targets"
>

my testing indicates that from 1 is significantly faster than from 2
postgres (8.4) cant factor "ARRAY[wid] <@" sufficiently to see how it
can use an index to help find the answer where as it can understand
"wid IN" and use an index on wid to find the rows it needs.

--
⚂⚃ 100% natural

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John Watts 2012-05-19 13:55:25 Re: difference in query plan when db is restored
Previous Message John Watts 2012-05-19 11:04:27 Re: difference in query plan when db is restored