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 43960200C2A for ; Wed, 15 Feb 2017 00:43:47 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 42278160B6D; Tue, 14 Feb 2017 23:43:47 +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 8AFF7160B5F for ; Wed, 15 Feb 2017 00:43:46 +0100 (CET) Received: (qmail 84653 invoked by uid 500); 14 Feb 2017 23:43:45 -0000 Mailing-List: contact issues-help@nifi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@nifi.apache.org Delivered-To: mailing list issues@nifi.apache.org Received: (qmail 84643 invoked by uid 99); 14 Feb 2017 23:43:45 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Feb 2017 23:43:45 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 57A6B1A0767 for ; Tue, 14 Feb 2017 23:43:45 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.198 X-Spam-Level: X-Spam-Status: No, score=-1.198 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id PvwOPaNFM6_M for ; Tue, 14 Feb 2017 23:43:44 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id EEDCC5FCD0 for ; Tue, 14 Feb 2017 23:43:43 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 2F27AE0740 for ; Tue, 14 Feb 2017 23:43:42 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id DC5EF24121 for ; Tue, 14 Feb 2017 23:43:41 +0000 (UTC) Date: Tue, 14 Feb 2017 23:43:41 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@nifi.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (NIFI-3268) Add AUTO_INCREMENT column in GenerateTableFetch to benefit index MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 14 Feb 2017 23:43:47 -0000 [ https://issues.apache.org/jira/browse/NIFI-3268?page=3Dcom.atlassian.= jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D15866= 946#comment-15866946 ]=20 ASF GitHub Bot commented on NIFI-3268: -------------------------------------- Github user qfdk commented on a diff in the pull request: https://github.com/apache/nifi/pull/1376#discussion_r101172664 =20 --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processor= s/src/main/java/org/apache/nifi/processors/standard/GenerateTableFetch.java= --- @@ -223,19 +237,34 @@ public void onTrigger(final ProcessContext contex= t, final ProcessSessionFactory } final int numberOfFetches =3D (partitionSize =3D=3D 0) ? r= owCount : (rowCount / partitionSize) + (rowCount % partitionSize =3D=3D 0 ?= 0 : 1); =20 + if("null".equals(indexValue)) { + // Generate SQL statements to read "pages" of data + for (int i =3D 0; i < numberOfFetches; i++) { + FlowFile sqlFlowFile; =20 - // Generate SQL statements to read "pages" of data - for (int i =3D 0; i < numberOfFetches; i++) { - FlowFile sqlFlowFile; + Integer limit =3D partitionSize =3D=3D 0 ? null : = partitionSize; + Integer offset =3D partitionSize =3D=3D 0 ? null := i * partitionSize; + final String query =3D dbAdapter.getSelectStatemen= t(tableName, columnNames, whereClause, StringUtils.join(maxValueColumnNameL= ist, ", "), limit, offset); + sqlFlowFile =3D session.create(); + sqlFlowFile =3D session.write(sqlFlowFile, out -> = { + out.write(query.getBytes()); + }); + session.transfer(sqlFlowFile, REL_SUCCESS); + } + }else { + for (int i =3D 0; i < numberOfFetches; i++) { + FlowFile sqlFlowFile; =20 - Integer limit =3D partitionSize =3D=3D 0 ? null : part= itionSize; - Integer offset =3D partitionSize =3D=3D 0 ? null : i *= partitionSize; - final String query =3D dbAdapter.getSelectStatement(ta= bleName, columnNames, whereClause, StringUtils.join(maxValueColumnNameList,= ", "), limit, offset); - sqlFlowFile =3D session.create(); - sqlFlowFile =3D session.write(sqlFlowFile, out -> { - out.write(query.getBytes()); - }); - session.transfer(sqlFlowFile, REL_SUCCESS); + Integer limit =3D partitionSize; + whereClause =3D indexValue + " >=3D " + limit * i; --- End diff -- =20 Thank you for your advice. I will work on it and solve the conflit. > Add AUTO_INCREMENT column in GenerateTableFetch to benefit index > ---------------------------------------------------------------- > > Key: NIFI-3268 > URL: https://issues.apache.org/jira/browse/NIFI-3268 > Project: Apache NiFi > Issue Type: Improvement > Components: Core Framework > Affects Versions: 1.1.1 > Environment: - ubuntu 16.04 > - java version "1.8.0_111" > - Java(TM) SE Runtime Environment (build 1.8.0_111-b14) > - Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode) > Reporter: qfdk > Labels: easyfix > Fix For: 1.2.0 > > > I added AUTO_INCREMENT column in GenerateTableFetch to benefit index col= umn > By default this processor uses OFFSET, i have problems with large data. = somme column has index so we could use index to speed up query time. > I posted question here : > https://community.hortonworks.com/questions/72586/how-can-i-use-an-array-= with-putelasticsearch.html > If you indexed un column (id), you could use this sql > ``` > select xxx > From xxxxx > where 200000=3D>id > order by id > limit 200000 > ``` > =E2=80=9COFFSET is bad for skipping previous rows.=E2=80=9D [Online]. Ava= ilable: http://Use-The-Index-Luke.com/sql/partial-results/fetch-next-page. = [Accessed: 27-Dec-2016]. > Thank you in advance -- This message was sent by Atlassian JIRA (v6.3.15#6346)