Return-Path: X-Original-To: apmail-cloudstack-issues-archive@www.apache.org Delivered-To: apmail-cloudstack-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AF9BEDB1F for ; Wed, 22 May 2013 13:03:22 +0000 (UTC) Received: (qmail 65669 invoked by uid 500); 22 May 2013 13:03:23 -0000 Delivered-To: apmail-cloudstack-issues-archive@cloudstack.apache.org Received: (qmail 65575 invoked by uid 500); 22 May 2013 13:03:22 -0000 Mailing-List: contact issues-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list issues@cloudstack.apache.org Received: (qmail 65551 invoked by uid 500); 22 May 2013 13:03:22 -0000 Delivered-To: apmail-incubator-cloudstack-issues@incubator.apache.org Received: (qmail 65546 invoked by uid 99); 22 May 2013 13:03:22 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 May 2013 13:03:22 +0000 Date: Wed, 22 May 2013 13:03:22 +0000 (UTC) From: "Kishan Kavala (JIRA)" To: cloudstack-issues@incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CLOUDSTACK-2625) Duplicate usage records when listing large number of records 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/CLOUDSTACK-2625?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13664071#comment-13664071 ] Kishan Kavala commented on CLOUDSTACK-2625: ------------------------------------------- Also, it is better to have order by asc. Records can change while querying subsequent pages. > Duplicate usage records when listing large number of records > ------------------------------------------------------------ > > Key: CLOUDSTACK-2625 > URL: https://issues.apache.org/jira/browse/CLOUDSTACK-2625 > Project: CloudStack > Issue Type: Bug > Security Level: Public(Anyone can view this level - this is the default.) > Components: Usage > Reporter: Kishan Kavala > Fix For: 4.2.0 > > > listUsageRecords sorts results by start_date. Using pagination, sa,ple mysql query is as follows. > SELECT cloud_usage.id, cloud_usage.zone_id, cloud_usage.account_id, > cloud_usage.domain_id, cloud_usage.description, cloud_usage.usage_display, > cloud_usage.usage_type, cloud_usage.raw_usage, cloud_usage.vm_instance_id, > cloud_usage.vm_name, cloud_usage.offering_id, cloud_usage.template_id, > cloud_usage.usage_id, cloud_usage.type, cloud_usage.size, > cloud_usage.virtual_size, cloud_usage.network_id, cloud_usage.start_date, > cloud_usage.end_date FROM cloud_usage WHERE cloud_usage.usage_type = 9 AND > cloud_usage.start_date BETWEEN '2012-01-01 00:00:00' AND '2013-01-31 23:59:59' > AND cloud_usage.end_date BETWEEN '2012-01-01 00:00:00' AND '2013-01-31 > 23:59:59' ORDER BY cloud_usage.start_date DESC LIMIT 18000, 2000 > start_date is not unique and when querying large datasets, multiple pages can return the same data. > ORDER BY cloud_usage.start_date doesn't create a stable sorted dataset. > Query should include id in ORDER BY to make it stable. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira