Re: Matching several rows

From: Michael Glaesemann <grzm(at)myrealbox(dot)com>
To: Volkan YAZICI <yazicivo(at)ttnet(dot)net(dot)tr>
Cc: Ivan Steganov <istegan6(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Matching several rows
Date: 2006-01-18 12:59:03
Message-ID: A6164E21-A45C-4308-A38A-4CA86CA9A265@myrealbox.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Jan 18, 2006, at 21:48 , Volkan YAZICI wrote:

> AFAICS, the bottleneck in above query is ANY(ARRAY[]) clause usage.
> Instead of that, if you replace «rights = ANY(ARRAY[2,5,10])» with
> «rights IN (2,5,10)» it's overhead decreases to 0.200-0.300ms domain.

explain analyze
SELECT id
FROM (
SELECT id, sum(1) AS s
FROM urights
WHERE uright in (2,5,10)
GROUP BY id) AS t
WHERE s = 3;
QUERY PLAN
------------------------------------------------------------------------
-------------------------------------
Subquery Scan t (cost=1.14..1.19 rows=2 width=4) (actual
time=0.106..0.108 rows=1 loops=1)
-> HashAggregate (cost=1.14..1.17 rows=2 width=4) (actual
time=0.103..0.105 rows=1 loops=1)
Filter: (sum(1) = 3)
-> Seq Scan on urights (cost=0.00..1.10 rows=4 width=4)
(actual time=0.029..0.038 rows=5 loops=1)
Filter: ((uright = 2) OR (uright = 5) OR (uright = 10))
Total runtime: 0.386 ms
(6 rows)

Michael Glaesemann
grzm myrealbox com

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Ivan Steganov 2006-01-18 14:22:39 Re: Matching several rows
Previous Message Volkan YAZICI 2006-01-18 12:48:34 Re: Matching several rows