What is the equivalent of rownum

I have a splayed table partitioned by date and i want to restrict thesearch so that it returns immediately after say 100 rows are matched.I tried10# select from t where date > 2008.01.01and it looks like it is scanning more than one partition.So i guess #(take) is only taking the first 10 rows and not restricting thesearch.I don’t want to set the .Q.view because i want it to keepscanning until the required number of rows are fetched.ThanksBharani

In-Reply-To:
Sensitivity: Normal
Importance: Normal
Subject: Re: [personal kdb+] What is the equivalent of rownum
To: personal-kdbplus@googlegroups.com
From: “Manish Patel” <manni.patel>
Date: Fri, 7 Aug 2009 12:34:53 +0000

UmVhZCBpdCBiYWNrd2FyZHMgLSB5b3UncmUgZG9pbmcgdGhlIHNlbGVjdCBmaXJzdCBUSEVOIHRh
a2luZyAxMCByb3dzIGZyb20gdGhlIHJlc3VsdA0KDQpZb3Ugd2FudCAuUS5pbmQgKHRoZSBraW5k
LW9mIGVxdWl2YWxlbnQgb2YgImkiIGZvciBwYXJ0ZWQgdGFibGVkKQ0KDQoNClNlbnQgdXNpbmcg
QmxhY2tCZXJyea4gZnJvbSBPcmFuZ2UNCg0KLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCkZy
b206IGJoYXJhbmkgPGJoYXJhbmlfdm1zQHlhaG9vLmNvbT4NCg0KRGF0ZTogRnJpLCA3IEF1ZyAy
MDA5IDA1OjE0OjI1IA0KVG86IEtkYisgUGVyc29uYWwgRGV2ZWxvcGVyczxwZXJzb25hbC1rZGJw
bHVzQGdvb2dsZWdyb3Vwcy5jb20+DQpTdWJqZWN0OiBbcGVyc29uYWwga2RiK10gV2hhdCBpcyB0
aGUgZXF1aXZhbGVudCBvZiByb3dudW0NCg0KDQoNCkkgaGF2ZSBhIHNwbGF5ZWQgdGFibGUgcGFy
dGl0aW9uZWQgYnkgZGF0ZSBhbmQgaSB3YW50IHRvIHJlc3RyaWN0IHRoZQ0Kc2VhcmNoIHNvIHRo
YXQgaXQgcmV0dXJucyBpbW1lZGlhdGVseSBhZnRlciBzYXkgMTAwIHJvd3MgYXJlIG1hdGNoZWQu
DQoNCkkgdHJpZWQNCg0KMTAjIHNlbGVjdCBmcm9tIHQgd2hlcmUgZGF0ZSA+IDIwMDguMDEuMDEN
Cg0KYW5kIGl0IGxvb2tzIGxpa2UgaXQgaXMgc2Nhbm5pbmcgbW9yZSB0aGFuIG9uZSBwYXJ0aXRp
b24uU28gaSBndWVzcyAjDQoodGFrZSkgaXMgb25seSB0YWtpbmcgdGhlIGZpcnN0IDEwIHJvd3Mg
YW5kIG5vdCByZXN0cmljdGluZyB0aGUNCnNlYXJjaC5JIGRvbid0IHdhbnQgdG8gc2V0IHRoZSAu
US52aWV3IGJlY2F1c2UgaSB3YW50IGl0IHRvIGtlZXANCnNjYW5uaW5nIHVudGlsIHRoZSByZXF1
aXJlZCBudW1iZXIgb2Ygcm93cyBhcmUgZmV0Y2hlZC4NCg0KVGhhbmtzDQpCaGFyYW5pDQoNCg==

</manni.patel>

Isn’t .Q.ind a lookup for the partitioned table? It takes table andindices as argument and gives the result. I am sorry but i am not ableto figure out how that can help me in restricting the rows-BharaniOn Aug 7, 5:34?pm, “Manish Patel” <manni.pa…> wrote:> Read it backwards - you’re doing the select first THEN taking 10 rows from the result>> You want .Q.ind (the kind-of equivalent of “i” for parted tabled)>> Sent using BlackBerry? from Orange>>>> -----Original Message-----> From: bharani <bharani_…>>> Date: Fri, 7 Aug 2009 05:14:25> To: Kdb+ Personal Developers> Subject: [personal kdb+] What is the equivalent of rownum>> I have a splayed table partitioned by date and i want to restrict the> search so that it returns immediately after say 100 rows are matched.>> I tried>> 10# select from t where date > 2008.01.01>> and it looks like it is scanning more than one partition.So i guess #> (take) is only taking the first 10 rows and not restricting the> search.I don’t want to set the .Q.view because i want it to keep> scanning until the required number of rows are fetched.>> Thanks> Bharani</bharani_…></manni.pa…>

In-Reply-To: <6f0c653d-cbd2-45e2-8b79-2cacc94d2067@t11g2000prh.googlegroups.com>
Sensitivity: Normal
Importance: Normal
Subject: Re: [personal kdb+] Re: What is the equivalent of rownum
To: personal-k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GZpcnN0IDEwIHJvd3MgYW5kIG5vdCByZXN0cmljdGlu
ZyB0aGUNCj4gc2VhcmNoLkkgZG9uJ3Qgd2FudCB0byBzZXQgdGhlIC5RLnZpZXcgYmVjYXVzZSBp
IHdhbnQgaXQgdG8ga2VlcA0KPiBzY2FubmluZyB1bnRpbCB0aGUgcmVxdWlyZWQgbnVtYmVyIG9m
IHJvd3MgYXJlIGZldGNoZWQuDQo+DQo+IFRoYW5rcw0KPiBCaGFyYW5pDQoNCg==

</manni.patel>

The intension is to do some non-trivial search so i want to get 10rows from something like thisselect from t where date > 2001.01.01 , p=10, k=15where t is a splayed table partitioned by date-BharaniOn Aug 7, 6:25?pm, “Manish Patel” <manni.pa…> wrote:> I thought you just wanted the first 10 rows (10#). I’m simply suggesting somthing like>> .Q.ind[table;til 9]>> (Tho admittedly I’ve never used it so can’t tell you how efficient it is)>> Sent using BlackBerry? from Orange>>>> -----Original Message-----> From: bharani <bharani_…>>> Date: Fri, 7 Aug 2009 06:14:17> To: Kdb+ Personal Developers> Subject: [personal kdb+] Re: What is the equivalent of rownum>> Isn’t .Q.ind a lookup for the partitioned table? It takes table and> indices as argument and gives the result. I am sorry but i am not able> to figure out how that can help me in restricting the rows>> -Bharani>> On Aug 7, 5:34?pm, “Manish Patel” <manni.pa…> wrote:> > Read it backwards - you’re doing the select first THEN taking 10 rows from the result>> > You want .Q.ind (the kind-of equivalent of “i” for parted tabled)>> > Sent using BlackBerry? from Orange>> > -----Original Message-----> > From: bharani <bharani_…>>> > Date: Fri, 7 Aug 2009 05:14:25> > To: Kdb+ Personal Developers> > Subject: [personal kdb+] What is the equivalent of rownum>> > I have a splayed table partitioned by date and i want to restrict the> > search so that it returns immediately after say 100 rows are matched.>> > I tried>> > 10# select from t where date > 2008.01.01>> > and it looks like it is scanning more than one partition.So i guess #> > (take) is only taking the first 10 rows and not restricting the> > search.I don’t want to set the .Q.view because i want it to keep> > scanning until the required number of rows are fetched.>> > Thanks> > Bharani</bharani_…></manni.pa…></bharani_…></manni.pa…>

Date: Mon, 10 Aug 2009 13:32:01 +0100Message-ID: <1855e77f0908100532w4744cec0p7dc9a844fe2f1fe2@mail.gmail.com>Subject: Re: [personal kdb+] Re: What is the equivalent of rownumFrom: Attila Vrabecz <attila.vrabecz>To: personal-kdbplus@googlegroups.comq){r:();I:-1;while[(Icount r,:select from quote wheredate=x I+:1,sym=`A];r}date where date>2001.01.01should be one way to approach itAttilaOn Fri, Aug 7, 2009 at 2:29 PM, bharani<bharani_vms> wrote:>> The intension is to do some non-trivial search so i want to get 10> rows from something like this>> select from t where date > 2001.01.01 , p=10, k=15>> where t is a splayed table partitioned by date>> -Bharani>> On Aug 7, 6:25?pm, “Manish Patel” <manni.pa…> wrote:>> I thought you just wanted the first 10 rows (10#). I’m simply suggesting somthing like>>>> .Q.ind[table;til 9]>>>> (Tho admittedly I’ve never used it so can’t tell you how efficient it is)>>>> Sent using BlackBerry? from Orange>>>>>>>> -----Original Message----->> From: bharani <bharani_…>>>>> Date: Fri, 7 Aug 2009 06:14:17>> To: Kdb+ Personal Developers>> Subject: [personal kdb+] Re: What is the equivalent of rownum>>>> Isn’t .Q.ind a lookup for the partitioned table? It takes table and>> indices as argument and gives the result. I am sorry but i am not able>> to figure out how that can help me in restricting the rows>>>> -Bharani>>>> On Aug 7, 5:34?pm, “Manish Patel” <manni.pa…> wrote:>> > Read it backwards - you’re doing the select first THEN taking 10 rows from the result>>>> > You want .Q.ind (the kind-of equivalent of “i” for parted tabled)>>>> > Sent using BlackBerry? from Orange>>>> > -----Original Message----->> > From: bharani <bharani_…>>>>> > Date: Fri, 7 Aug 2009 05:14:25>> > To: Kdb+ Personal Developers>> > Subject: [personal kdb+] What is the equivalent of rownum>>>> > I have a splayed table partitioned by date and i want to restrict the>> > search so that it returns immediately after say 100 rows are matched.>>>> > I tried>>>> > 10# select from t where date > 2008.01.01>>>> > and it looks like it is scanning more than one partition.So i guess #>> > (take) is only taking the first 10 rows and not restricting the>> > search.I don’t want to set the .Q.view because i want it to keep>> > scanning until the required number of rows are fetched.>>>> > Thanks>> > Bharani> >></bharani_…></manni.pa…></bharani_…></manni.pa…></bharani_vms></attila.vrabecz>

I have to read a bit more to fully understand your solution but fornow i am looping and setting .Q.view like this.Q.viewalldate:datei:0c:0while[c < 11;.Q.view alldate[i];r,:select from t where date >2001.01.01 , p=10, k=15 ;c:count r;i+:1]-BharaniOn Aug 10, 5:32?pm, Attila Vrabecz <attila.vrab…> wrote:> q){r:();I:-1;while[(Icount r,:select from quote where> date=x I+:1,sym=`A];r}date where date>2001.01.01>> should be one way to approach it> Attila>>>> On Fri, Aug 7, 2009 at 2:29 PM, bharani<bharani_…> wrote:>> > The intension is to do some non-trivial search so i want to get 10> > rows from something like this>> > select from t where date > 2001.01.01 , p=10, k=15>> > where t is a splayed table partitioned by date>> > -Bharani>> > On Aug 7, 6:25?pm, “Manish Patel” <manni.pa…> wrote:> >> I thought you just wanted the first 10 rows (10#). I’m simply suggesting somthing like>> >> .Q.ind[table;til 9]>> >> (Tho admittedly I’ve never used it so can’t tell you how efficient it is)>> >> Sent using BlackBerry? from Orange>> >> -----Original Message-----> >> From: bharani <bharani_…>>> >> Date: Fri, 7 Aug 2009 06:14:17> >> To: Kdb+ Personal Developers> >> Subject: [personal kdb+] Re: What is the equivalent of rownum>> >> Isn’t .Q.ind a lookup for the partitioned table? It takes table and> >> indices as argument and gives the result. I am sorry but i am not able> >> to figure out how that can help me in restricting the rows>> >> -Bharani>> >> On Aug 7, 5:34?pm, “Manish Patel” <manni.pa…> wrote:> >> > Read it backwards - you’re doing the select first THEN taking 10 rows from the result>> >> > You want .Q.ind (the kind-of equivalent of “i” for parted tabled)>> >> > Sent using BlackBerry? from Orange>> >> > -----Original Message-----> >> > From: bharani <bharani_…>>> >> > Date: Fri, 7 Aug 2009 05:14:25> >> > To: Kdb+ Personal Developers> >> > Subject: [personal kdb+] What is the equivalent of rownum>> >> > I have a splayed table partitioned by date and i want to restrict the> >> > search so that it returns immediately after say 100 rows are matched.>> >> > I tried>> >> > 10# select from t where date > 2008.01.01>> >> > and it looks like it is scanning more than one partition.So i guess #> >> > (take) is only taking the first 10 rows and not restricting the> >> > search.I don’t want to set the .Q.view because i want it to keep> >> > scanning until the required number of rows are fetched.>> >> > Thanks> >> > Bharani</bharani_…></manni.pa…></bharani_…></manni.pa…></bharani_…></attila.vrab…>