Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 5753C632722 for ; Sun, 29 Aug 2010 10:18:35 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 03981-03 for ; Sun, 29 Aug 2010 13:18:26 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f46.google.com (mail-fx0-f46.google.com [209.85.161.46]) by mail.postgresql.org (Postfix) with ESMTP id D4BCB632585 for ; Sun, 29 Aug 2010 10:18:27 -0300 (ADT) Received: by fxm13 with SMTP id 13so2809569fxm.19 for ; Sun, 29 Aug 2010 06:18:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type :content-transfer-encoding; bh=Wf+pdcoY9pxGUnxWZBPKe3bJzFcUFOd0gDzciZO4ZMw=; b=u4bT6viig98BllgfLPhbhNwdJEuGqrXbQKQWe8lx6tXhRoAchMFJbzOELVIgd5S2Ji Fuw72/qzUjKsFQ4hqG9jqDQqLMy2T3vNAcHpyN3bMb700V56ddQgk/JTI3k4LhFCKrrY ffy4G8iOji/wbPSkKgMu/hkj08dIP/gyQG/nE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=VJxwK3m5B67H6FgyN5Ej5FWO+rG1xkL2Hh/LCXMtD53O8I0ZFCa16bafJlDIRVuFnG 5YFBRig2Fceqyji7f4hM3WttLBCJxxcQkthdXOHsAhGiStf4BQ6Hwtjll/3t8SbqrCQk 5AyG6lBCvJhrmgBlFZ9iKEwRlwGAhX6VLogVc= Received: by 10.223.111.137 with SMTP id s9mr2607589fap.30.1283087905557; Sun, 29 Aug 2010 06:18:25 -0700 (PDT) Received: from limbo.lan ([193.33.173.33]) by mx.google.com with ESMTPS id p2sm2859235fak.22.2010.08.29.06.18.24 (version=SSLv3 cipher=RC4-MD5); Sun, 29 Aug 2010 06:18:24 -0700 (PDT) Message-ID: <4C7A5E1E.6050205@gmail.com> Date: Sun, 29 Aug 2010 16:18:22 +0300 From: Volodymyr Kostyrko User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; uk-UA; rv:1.9.2.8) Gecko/20100807 Thunderbird/3.1.2 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: array can be slow when joining? Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201008/304 X-Sequence-Number: 40147 I don't clearly understand why this happens, but when I try join some tables using arrays I end up with: =# explain select count(*) from urls JOIN rules ON urls.tag && rules.tag; QUERY PLAN --------------------------------------------------------------------------------------- Aggregate (cost=1356.27..1356.28 rows=1 width=0) -> Nested Loop (cost=20.33..1354.96 rows=523 width=0) -> Seq Scan on rules (cost=0.00..1.01 rows=1 width=37) -> Bitmap Heap Scan on urls (cost=20.33..1347.42 rows=523 width=29) Recheck Cond: (urls.tag && rules.tag) -> Bitmap Index Scan on url_tag_g (cost=0.00..20.20 rows=523 width=0) Index Cond: (urls.tag && rules.tag) Here tag is text[] with list of tags. Whole select takes 142 ms. It drops down to 42 ms when I add some conditions that strip result table to zero length. What am I missing? Is there any other ways to overlap those ones? Or should I find "any other way"? -- Sphinx of black quartz judge my vow.