Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1agcCt-0001Bm-Cr for pgsql-performance@arkaria.postgresql.org; Thu, 17 Mar 2016 17:59:35 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1agcCs-0007g2-U6 for pgsql-performance@arkaria.postgresql.org; Thu, 17 Mar 2016 17:59:34 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1agcBC-0004bS-NZ for pgsql-performance@postgresql.org; Thu, 17 Mar 2016 17:57:50 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1agcBA-0000qZ-5D for pgsql-performance@postgresql.org; Thu, 17 Mar 2016 17:57:49 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u2HHvkip004025; Thu, 17 Mar 2016 13:57:46 -0400 From: Tom Lane To: Andreas Joseph Krogh cc: Evgeniy Shishkin , pgsql-performance Subject: Re: Searching GIN-index (FTS) and sort by timestamp-column In-reply-to: References: Comments: In-reply-to Andreas Joseph Krogh message dated "Thu, 17 Mar 2016 18:30:12 +0100" Date: Thu, 17 Mar 2016 13:57:46 -0400 Message-ID: <4024.1458237466@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Andreas Joseph Krogh writes: > På torsdag 17. mars 2016 kl. 18:20:23, skrev Tom Lane FWIW, the reason for that is that the int8_ops operator class that > btree_gin creates doesn't contain any cross-type operators.  Probably > wouldn't be that hard to fix if somebody wanted to put in the work. > Can you explain why it works when using prepared statement without casting? If you mean the example prepare fish AS SELECT del.id , del.received_timestamp FROM delivery del WHERE 1= 1 AND del.fts_all @@ to_tsquery('simple', $1) AND del.folder_id = $2 ORDER BY del.received_timestamp DESC LIMIT 101 OFFSET 0; you didn't provide any type for the parameter $2, so the parser had to infer a type, and the applicable heuristic here is "same type that's on the other side of the operator". So you ended up with "bigint = bigint" which is in the btree_gin operator class. If you'd specified the parameter's type as integer, it would've worked the same as Evgeniy's example. regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance