Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 0098C200D5C for ; Fri, 15 Dec 2017 17:00:56 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id F2E30160C14; Fri, 15 Dec 2017 16:00:55 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 46C0E160C06 for ; Fri, 15 Dec 2017 17:00:55 +0100 (CET) Received: (qmail 83349 invoked by uid 500); 15 Dec 2017 16:00:54 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 83337 invoked by uid 99); 15 Dec 2017 16:00:54 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Dec 2017 16:00:54 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 4FE53180161 for ; Fri, 15 Dec 2017 16:00:53 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.001 X-Spam-Level: X-Spam-Status: No, score=-0.001 tagged_above=-999 required=6.31 tests=[RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id NnVMpZxPL_LL for ; Fri, 15 Dec 2017 16:00:50 +0000 (UTC) Received: from post.selbstdenker.com (mail.selbstdenker.com [81.27.166.251]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id A12EB5F250 for ; Fri, 15 Dec 2017 16:00:49 +0000 (UTC) X-CGP-ClamAV-Result: CLEAN X-VirusScanner: Niversoft's CGPClamav Helper v1.19.2 (ClamAV engine v0.99.2) Received: from [81.27.162.131] (account maik@selbstdenker.ag HELO [81.27.162.221]) by selbstdenker.ag (CommuniGate Pro SMTP 6.2.0) with ESMTPSA id 14392126 for user@cayenne.apache.org; Fri, 15 Dec 2017 17:00:42 +0100 From: "Musall, Maik" Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: ILIKE vs. upper/lower with PostgreSQL Date: Fri, 15 Dec 2017 17:00:34 +0100 References: To: user@cayenne.apache.org In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.3273) archived-at: Fri, 15 Dec 2017 16:00:56 -0000 Hi Nikita, thanks for the reponse. However, changing hundreds of expressions to = something less elegant isn't really a compelling solution to me. So Hugi (who works on this project with me) solved it by creating a = custom alternative to PostgresQualifierTranslator which just omits the = ILIKE-related code. That way I get the regular SQL using UPPER(), which = is easily indexable. ILIKE is certainly useful for full text searches with CLOB/TEXT values = and in combination with GiST/GIN indexes, but IMHO not for regular = case-insensitive queries using b-tree indexes. So I'm not sure that = PostgresQualifierTranslator does the right thing here. How is everyone else indexing varchar columns for case-insensitive = queries on PostgreSQL? Maik > Am 15.12.2017 um 12:21 schrieb Nikita Timofeev = : >=20 > Hi, >=20 > I don't think it will be easy to change Cayenne translator behavior > (but still should be possible if necessary). > It may be easier to use upper().like() functions instead of > likeIgnoreCase() in your case. >=20 > I.e. you can do something like this: > = ObjectSelect.query(MyTable.class).where(MyTable.MYCOLUMN.upper().like("FOO= %")) >=20 >=20 > On Fri, Dec 15, 2017 at 11:44 AM, Musall, Maik = wrote: >> Hi all, >>=20 >> after migrating an EOF application to Cayenne, I noticed many queries = running much slower than before and with more load on the database. = Turns out that Cayenne generates queries using ILIKE where EOF used to = generate UPPER() comparisons. Example: >>=20 >> EOF: SELECT * FROM mytable t0 WHERE UPPER(mycolumn) LIKE = UPPER('foo%') >> Cayenne: SELECT * FROM mytable t0 WHERE mycolumn ILIKE 'foo%' >>=20 >> The database is PostgreSQL 9.5, and I used to cover the UPPER() = queries with function-based indexes on UPPER(column), which used to work = very well. >>=20 >> ILIKE is not as easy to index with PostgreSQL, because it's = semantically different, especially with languages that don't have a = simple alphabet. There are GiST and GIN index types in PostgreSQL, but = those have other drawbacks (too many hits for short columns, needing = additional table accesses, no sorting by index, expensive updates in the = case of GiST, and so on). >>=20 >> So, my question is: can I change what Cayenne generates here and = generate UPPER() or LOWER() comparisons so that I can continue using the = existing indexes, and what would be the recommended way to do that? >>=20 >> Thanks >> Maik >>=20 >=20 >=20 >=20 > --=20 > Best regards, > Nikita Timofeev