Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 15325 invoked from network); 25 Feb 2011 05:18:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 25 Feb 2011 05:18:09 -0000 Received: (qmail 6692 invoked by uid 500); 25 Feb 2011 05:18:08 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 6497 invoked by uid 500); 25 Feb 2011 05:18:06 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 6485 invoked by uid 99); 25 Feb 2011 05:18:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Feb 2011 05:18:05 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Feb 2011 05:18:04 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 3B7C91B62A0 for ; Fri, 25 Feb 2011 05:17:44 +0000 (UTC) Date: Fri, 25 Feb 2011 05:17:44 +0000 (UTC) From: "Mike Matrigali (JIRA)" To: derby-dev@db.apache.org Message-ID: <2130568379.15414.1298611064239.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <169645521.12661.1298519438645.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] Commented: (DERBY-5066) full table scan when index is used, taking extremely long time in JDBC MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DERBY-5066?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12999219#comment-12999219 ] Mike Matrigali commented on DERBY-5066: --------------------------------------- there is probably some tuning that could be done on the sort, as bryan mentions. It could be you need to start your jvm with some bigger initial heaps. But as I understand the goal of the app derby is never going to give you what you are looking for if it does a sort rather than do sort avoidance. You have 3 choices: 1) assuming PID is a unique key, first issue an order select to get all the PID's of interest and then as you fill each row in the UI do a stored prepared statement to look up the data associated with the PID. I believe if you just select the stuff in the index it will never do a sort. 2) use optimizer hints to force the use of the index in your query. 3) use fetch/offset feature added recently to derby to get "chunks" of data. I don't know much about this feature so am not sure if it will avoid the sort or not. > full table scan when index is used, taking extremely long time in JDBC > ---------------------------------------------------------------------- > > Key: DERBY-5066 > URL: https://issues.apache.org/jira/browse/DERBY-5066 > Project: Derby > Issue Type: Bug > Components: Eclipse Plug-in, JDBC > Affects Versions: 10.7.1.1 > Environment: Windows XP environment > Reporter: George Xu > Attachments: LogXData.rar > > > When a very large table (500k rows) is used with a column is indexed. select * from tab where pid > 0 order by pid takes extremely longer time than select * from tab order by pid. Actually, it is 100 times slower. However, in IJ, ther performance seems to be similar. PID column is indexed. > Here is the code snipplet > import java.sql.Connection; > import java.sql.DriverManager; > import java.sql.ResultSet; > import java.sql.SQLException; > import java.sql.Statement; > public class TestPerformance { > //20343 mill-sec > static String s1 = "SELECT TIMESTAMP, HOSTPORT AS \"HOST ID\", PID, SESSIONID, REQUESTID, " + > "SUBREQUESTID, STEPID, TID, COMPONENT, BUILDNUM, " + > "LOGLEVELORIG AS \"LEVEL\", LOGGER, OPERATION, OBJECTTYPE, OBJECTPATH, " + > "STATUS, MESSAGE, DATA, NDX FROM LOGDATA871218 where PID > 0 ORDER BY PID"; > //297 million sec. > static String s2 = "SELECT TIMESTAMP, HOSTPORT AS \"HOST ID\", PID, SESSIONID, REQUESTID, " + > "SUBREQUESTID, STEPID, TID, COMPONENT, BUILDNUM, " + > "LOGLEVELORIG AS \"LEVEL\", LOGGER, OPERATION, OBJECTTYPE, OBJECTPATH, " + > "STATUS, MESSAGE, DATA, NDX FROM LOGDATA871218 ORDER BY PID"; > public static void main(String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException { > Statement stmt3; > try { > //connect'jdbc:derby:C:/devroot/runtime-New_configuration/LogXData'; > String db = "C:/devroot/runtime-New_configuration/LogXData"; > String driver = "org.apache.derby.jdbc.EmbeddedDriver"; > Class.forName(driver).newInstance(); > Connection con = DriverManager.getConnection("jdbc:derby:"+db); > stmt3 = con.createStatement(ResultSet.FETCH_FORWARD, > ResultSet.TYPE_FORWARD_ONLY); > long startTime3 = System.currentTimeMillis(); > ResultSet rs3 = stmt3.executeQuery(s1); > long elapsed3 = System.currentTimeMillis() - startTime3; > System.out.println("Statment.executeQuery Dup: " + elapsed3); > } catch (SQLException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > } > } -- This message is automatically generated by JIRA. - For more information on JIRA, see: http://www.atlassian.com/software/jira