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.92) (envelope-from ) id 1jDuaI-0000pP-SP for pgsql-admin@arkaria.postgresql.org; Mon, 16 Mar 2020 18:35:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jDuaH-0006Ch-Fr for pgsql-admin@arkaria.postgresql.org; Mon, 16 Mar 2020 18:35:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jDuaH-0006CM-66 for pgsql-admin@lists.postgresql.org; Mon, 16 Mar 2020 18:35:29 +0000 Received: from mout.perfora.net ([74.208.4.196]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jDuaE-00063M-Ib for pgsql-admin@postgresql.org; Mon, 16 Mar 2020 18:35:28 +0000 Received: from [192.168.1.143] ([98.169.208.7]) by mrelay.perfora.net (mreueus003 [74.208.5.2]) with ESMTPSA (Nemesis) id 0Lr0UP-1jqYvJ0Vjn-00eduf; Mon, 16 Mar 2020 19:35:22 +0100 Subject: Re: Explain plan on a Select query To: John Scalia Cc: Pgsql-admin References: <83029EBF-241B-499B-881A-9057399DC67B@gmail.com> From: MichaelDBA Message-ID: Date: Mon, 16 Mar 2020 14:35:18 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 PostboxApp/7.0.12 MIME-Version: 1.0 In-Reply-To: <83029EBF-241B-499B-881A-9057399DC67B@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Provags-ID: V03:K1:pUlJl54f50EDx23y3RugaLIk8g+ck2UmzycIVuvZS3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TdZqfDvcaW+Kcw2uodCN08r+4ti3mrO65Zr1zIy57 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi John, How many rows are in the table?  If the table is small with respect to row count, and the pages are not very fragmented, ie, not many pages, then PG is just doing the right thing here: seq scan is less expensive than index scan in those cases.  You can turn off enable_seqscan to just make sure it does use the index. Regards, Michael Vitale John Scalia wrote on 3/16/2020 12:26 PM: > I’m a bit confused on an explain plan I just generated for a select statement. The plan’s first line begins with the word “Append” followed by the usual (cost....) data. What in the world is an Append doing here? I’ve recently performed another analyze on the table, btw. > > Also, the query does not seem to be using an index, as the explain shows a pair of sequential scans, speaking of which, the second sequential scan shows it’s on a table, called _test. Which is a little strange, considering that does not exist. > > The query’s where clause is on a varchar(25) field. And that field has both a btree index and a trigram index on it. I’ve tried using where =, like, and ~ in order to see if I can get it to use an index. All attempts continue to say sequential scan. > — > Jay > Sent from my iPad >