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 B19F6200B7D for ; Sat, 10 Sep 2016 09:48:15 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id B0250160ABE; Sat, 10 Sep 2016 07:48:15 +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 035E3160AB2 for ; Sat, 10 Sep 2016 09:48:14 +0200 (CEST) Received: (qmail 82590 invoked by uid 500); 10 Sep 2016 07:48:14 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 82578 invoked by uid 99); 10 Sep 2016 07:48:13 -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; Sat, 10 Sep 2016 07:48:13 +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 445691805DB for ; Sat, 10 Sep 2016 07:48:13 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.821 X-Spam-Level: X-Spam-Status: No, score=-0.821 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.de Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id ctQtqb7Lwm9b for ; Sat, 10 Sep 2016 07:48:10 +0000 (UTC) Received: from nm14-vm6.bullet.mail.ne1.yahoo.com (nm14-vm6.bullet.mail.ne1.yahoo.com [98.138.91.107]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 59B055F36A for ; Sat, 10 Sep 2016 07:48:10 +0000 (UTC) Received: from [98.138.101.130] by nm14.bullet.mail.ne1.yahoo.com with NNFMP; 10 Sep 2016 07:48:04 -0000 Received: from [98.138.89.249] by tm18.bullet.mail.ne1.yahoo.com with NNFMP; 10 Sep 2016 07:48:04 -0000 Received: from [127.0.0.1] by omp1041.mail.ne1.yahoo.com with NNFMP; 10 Sep 2016 07:48:04 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 118102.77931.bm@omp1041.mail.ne1.yahoo.com X-YMail-OSG: oowqTHkVM1lwUUsBs7QX3Q3G9qWqxSuk3dUGql05Vo6VN9GhHcUf6jCmwLg3sel 8hQEfTLRcn.o.DOIKcZsZ5Uo4Ub59UUW7nWpgKhtP8ccktgbA81Mb5aFeM7w1qgaQtCmnoF3bASj MIkh0bkUj2ZZK9lUAgzLsCPFl36zTVS6hvLKdghd2dNJn9TSngbN.LBwcyFYZJNvzSk8viYjYUU5 z_JEMN0NNP0WyKWZQ7Z7CcIRgUmczwtQr2vXVtufzJ8YOIa.67YwH4OeXvyGnjnKfaA7lk4ycGjM .rbHudpcaklbZETZ6eLrnqetTlu4qCS6Qdi_n7hnbL391NqA2bV9mEBOAg2DhREWouWRCOWxG5KI FDkOHTLOFCH5cZ0rT0nPbE1F4VoYdiFb68AEpaeq1bmURoPozEB9BRuI0FWP31aowiKLU561ArLS 0GNokjjbzS.5kvjpPQmjYSLF.pD3w1goYt0J079Knzzx.mBhv7PozHp2e1DLDh6Qz4tjc8xJprXj 0R5i4kKeKdClCFBnTuawhfnZqHP0JEraeXufE02hlTH5q Received: from jws10050.mail.ne1.yahoo.com by sendmailws107.mail.ne1.yahoo.com; Sat, 10 Sep 2016 07:48:03 +0000; 1473493683.705 Date: Sat, 10 Sep 2016 07:48:02 +0000 (UTC) From: Mark Struberg Reply-To: Mark Struberg To: "users@openjpa.apache.org" Message-ID: <953055937.1928316.1473493682329@mail.yahoo.com> In-Reply-To: References: Subject: Re: weird bug with order by (2.4.1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit archived-at: Sat, 10 Sep 2016 07:48:15 -0000 Hi Marc! Can you please try with 2.4.0? Is the generated query the same or without the column? LieGrue, strub On Saturday, 10 September 2016, 2:14, Marc Logemann wrote: > > >Hi, > >i suspect i found a bug which has bad consequences on MariaDB not using an >index anymore. Lets take this JPAQL: > >select d from Distribution d join fetch d.distributionContainerList where >d.client = ?1 and d.deleted = ?2 order by d.oid desc > >My Distribution entity is quite big when it comes to 1:n relations and >stuff. So i wont get into the details here, but this JPAQL will result in >the following SQL (compressed because too big otherwise): > >SELECT t0.oid, t0.jpaversion, t0.created, t0.createdby, ... > FROM distribution t0 LEFT OUTER JOIN dist_altfrom t1 ON t0.altfrom_oid >= t1.oid > LEFT OUTER JOIN clients t3 ON t0.client_oid = t3.oid LEFT OUTER >JOIN > cmrcarrier t17 ON t0.cmrcarrier_oid = t17.oid LEFT OUTER JOIN >countries > t20 ON t0.empf_country = t20.isocode2 LEFT OUTER JOIN users t21 ON > t0.user_oid = t21.oid INNER JOIN dist_container t24 ON t0.oid = > t24.distribution_oid LEFT OUTER JOIN countries t2 ON t1.country = > t2.isocode2 LEFT OUTER JOIN address t4 ON t3.address_oid = t4.oid >LEFT > OUTER JOIN bankaccount t6 ON t3.bankaccount_oid = t6.oid LEFT OUTER > JOIN communication t7 ON t3.communication_oid = t7.oid LEFT OUTER >JOIN > persons t8 ON t3.cperson_oid = t8.oid LEFT OUTER JOIN bankaccount >t10 > ON t3.nnbankaccount_oid = t10.oid LEFT OUTER JOIN workplaces t11 ON > t3.workplaceoid = t11.oid LEFT OUTER JOIN address t18 ON > t17.address_oid = t18.oid LEFT OUTER JOIN communication t19 ON > t17.communication_oid = t19.oid LEFT OUTER JOIN persons t22 ON > t21.person_oid = t22.oid LEFT OUTER JOIN workplaces t23 ON > t21.workplaceoid = t23.oid LEFT OUTER JOIN distribution t25 ON > t24.old_distribution_oid = t25.oid LEFT OUTER JOIN countries t5 ON > t4.country_id = t5.isocode2 LEFT OUTER JOIN communication t9 ON > t8.communication_oid = t9.oid LEFT OUTER JOIN balance t12 ON > t11.balance = t12.oid LEFT OUTER JOIN balance t13 ON t11.balance2 = > t13.oid LEFT OUTER JOIN clients t14 ON t11.client_oid = t14.oid >LEFT > OUTER JOIN printer t15 ON t11.labelprinter = t15.oid LEFT OUTER >JOIN > printer t16 ON t11.laserprinter = t16.oid > WHERE (t0.client_oid = ? AND t0.deleted = ?) > ORDER BY t0.oid DESC, t24.distribution_oid ASC LIMIT ?, ? > > >Just look at the order by clause in the SQL. It correctly used t0.oid >because JPAQL said so. But why on earth is there another order clause with >the field "t24.distribution_oid" ?? This is a back reference for a 1:n >relation from Table "dist_container" back to "distribution". > >The real problem is: as soon as there is another sorting parameter from a >joined table, MariaDB doesnt use my ForeignKey Index anymore and does a >FULL-Scan on the t24 table, which is pretty heavy on a multi million >records table. When i leave out that ugly t24.distribution_oid ordering >field, everything is fast and ok. > >Can anyone explain to me how this ordering field gets into the picture? > >thanks >marc > > >