From: Craig L Russell Date: November 29 2012 4:00pm Subject: Re: NDB API Order by with Limit List-Archive: http://lists.mysql.com/cluster/8456 Message-Id: MIME-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Hi Syed, With ndb api, you have a choice how to scan the table. If you have indexes on both id1 and id2, you can index scan on either one. But ndb api does not do any client-side ordering according to a different index, or limit results by itself. So in your case, you could scan by id1, limiting your scan to only those rows where id1 = 1, and then in your client code order by id2. Or you can scan by id2, with a filter that operates in the ndbd node to select only rows where id1 = 1. And you can cut your scan short after you have reached your limit. Depending on the cardinality of your table and the selectivity of your indexes you need to choose which of the above strategies would be better. This is basically what the mysqld optimizer does for you. Regards, Craig On Nov 29, 2012, at 3:02 AM, Syed Shahanavaz wrote: > > > Hi Johan, > > > > Thanks for the reply. Since I need perform something like example > operation > using NDB API [Example: select * from tbltest where id1=1 order by > id2 limit > 5;]. > > Is it possible to do using for full table NDB scan! > > > > Kindly let me know if you suggest any alternatives. > > > > Best Regards, > > SYED > > > > > > From: Johan Andersson [mailto:johan@stripped] > Sent: Thursday, November 29, 2012 1:10 PM > To: Syed Shahanavaz > Cc: cluster@stripped > Subject: Re: NDB API Order by with Limit > > > > Hi, > > > > Not that I am aware of. > > NdbIndexScanOperation::readTuples(..) let's you order by index > order , but > if you then want to sort it based on a particular column (if you are > not > happy with the index order) you would have to do it yourself in the > application. > > > > Best regards, > > Johan > > > > On Thu, Nov 29, 2012 at 10:16 AM, Syed Shahanavaz > > wrote: > > Hi, > > > > I am currently using NDB API for developing some web application. > > I faced a specific requirement where results from NDB Index scan > have to be > ordered ascending on a specific column and limit results to a specific > value. > > Is there any way to order by on specific column in NDB API? > > > > Best Regards, > > SYED > > > > > > Craig L Russell Architect, Oracle http://db.apache.org/jdo 408 276-5638 mailto:Craig.Russell@stripped P.S. A good JDO? O, Gasp!