Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gTtJk-000772-P9 for pgsql-performance@arkaria.postgresql.org; Mon, 03 Dec 2018 18:51:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gTtJj-0007yG-9X for pgsql-performance@arkaria.postgresql.org; Mon, 03 Dec 2018 18:51:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gTtJi-0007y8-Th for pgsql-performance@lists.postgresql.org; Mon, 03 Dec 2018 18:51:39 +0000 Received: from athena.simkin.ca ([2607:f040:1001:2::ff:2]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gTtJf-0007lS-JV for pgsql-performance@lists.postgresql.org; Mon, 03 Dec 2018 18:51:37 +0000 Received: from skynet.simkin.ca (skynet.simkin.ca [IPv6:2607:f040:1001:103::1000]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by athena.simkin.ca (Postfix) with ESMTPSA id 26052DC69709 for ; Mon, 3 Dec 2018 10:51:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.simkin.ca; s=athena; t=1543863090; bh=SV7LzI0vt3zfUgc0wihnp4Hf8VpLa0eBwLz9y2pceOk=; h=Subject:From:To:Date:From:To:Subject:Date:Reply-To; b=lVqN0xvwxHKCX8ErHhAzc+k6YntHB6ejd3NsMrAnj0qew1JtOuUYLFpNXWCTVER1i 3h+6uprkuNEK45WeBf1pMv5JDctZ4mOkO9/SHG23zbvxHxoR6pWhqIiX8ydS4L6/ud c/ER4ljIzzIOVx2aWGGYCjHXIb+HESw3ODEctSi0879nej4t+WR0VPQKlMzimFztgk IxTVSlyQDHmMC91B7wJeyRApmRFx03ZQp+13EUxcOyIiRHgEZI6N0Q6S5e6fZ0ssOO GEOaIjvlaaTOE46ousxD8lHoMULlLj3w3klS71ts6lWrLfKTAdStha0bVHLWLj3I8H aNTyvUzoMLjjA== Received: from skynet.simkin.ca (skynet.simkin.ca [IPv6:::1]) by skynet.simkin.ca (Postfix) with ESMTP id D336F21A5CB84 for ; Mon, 3 Dec 2018 10:51:29 -0800 (PST) Message-ID: <1543863089.8141.15.camel@lists.simkin.ca> Subject: Re: Slow Bitmap Index Scan From: Alan Hodgson To: "pgsql-performance@lists.postgresql.org" Date: Mon, 03 Dec 2018 10:51:29 -0800 In-Reply-To: References: <05111C93-69B4-4D5B-8AD3-8C9C47E0F01E@motus.com> <20181128191753.GM30707@telsasoft.com> Content-Type: multipart/alternative; boundary="=-sCjPmgx5Pz+Oq4e1/lJZ" X-PGP-Key: fp="EF82 6F8D A3BA A096 FFA3 05F2 A7A0 40A5 34E5 AA0B"; id="0x34E5AA0B"; get=; get= X-Mailer: Evolution 3.24.6 Mime-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --=-sCjPmgx5Pz+Oq4e1/lJZ Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit On Mon, 2018-12-03 at 18:41 +0000, Scott Rankin wrote: > Upon further analysis, this is - unsurprisingly - taking place when we have multiple prefixed search terms in a ts_query going against a tsvector index. > > We have roughly 30 million rows in the table, and the search column is basically a concatenation of a location's name (think "Walmart #123456") and its street address. > > We use these searches mostly for autocompleting of a location search. So the search for that record above might be "Walmart 123", which we change to be to_tsquery('walmart:* &123:*'). We prefix both terms to correct for misspellings or lazy typing. > > Is it unrealistic to think that we could have sub-1000ms searches against that size of a table? > We've found trigram indexes to be much faster and more useful for these types of searches than full-text. https://www.postgresql.org/docs/10/pgtrgm.html Might be worth a try, if you haven't tested them before. --=-sCjPmgx5Pz+Oq4e1/lJZ Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: 7bit
On Mon, 2018-12-03 at 18:41 +0000, Scott Rankin wrote:
Upon further analysis, this is - unsurprisingly - taking place when we have multiple prefixed search terms in a ts_query going against a tsvector index.

We have roughly 30 million rows in the table, and the search column is basically a concatenation of a location's name (think "Walmart #123456") and its street address.

We use these searches mostly for autocompleting of a location search.  So the search for that record above might be "Walmart 123", which we change to be to_tsquery('walmart:* &123:*').  We prefix both terms to correct for misspellings or lazy typing.

Is it unrealistic to think that we could have sub-1000ms searches against that size of a table?


We've found trigram indexes to be much faster and more useful for these types of searches than full-text.


Might be worth a try, if you haven't tested them before.
--=-sCjPmgx5Pz+Oq4e1/lJZ--